]> code.delx.au - gnu-emacs-elpa/commitdiff
Simplify coffee-indent-line and coffee-previous-indent.
authorReuben Thomas <rrt@sc3d.org>
Sat, 12 May 2012 20:06:53 +0000 (21:06 +0100)
committerReuben Thomas <rrt@sc3d.org>
Sat, 12 May 2012 20:06:53 +0000 (21:06 +0100)
As a result, remove coffee-line-as-string and coffee-line-empty-p.

coffee-mode.el

index dd0e0096ec969f30cc9fe7814be1c180999e7895..e4ca162be5af4d1c39b2eb6d37b506c6311e3ee4 100644 (file)
@@ -123,14 +123,6 @@ with CoffeeScript."
 (defvar coffee-mode-map (make-keymap)
   "Keymap for CoffeeScript major mode.")
 
-;;
-;; Macros
-;;
-
-(defmacro coffee-line-as-string ()
-  "Returns the current line as a string."
-  `(buffer-substring (point-at-bol) (point-at-eol)))
-
 ;;
 ;; Commands
 ;;
@@ -437,13 +429,8 @@ output in a compilation buffer."
   (if (= (point) (point-at-bol))
       (insert-tab)
     (save-excursion
-      (let ((prev-indent 0) (cur-indent 0))
-        ;; Figure out the indentation of the previous line
-        (setq prev-indent (coffee-previous-indent))
-
-        ;; Figure out the current line's indentation
-        (setq cur-indent (current-indentation))
-
+      (let ((prev-indent (coffee-previous-indent))
+            (cur-indent (current-indentation)))
         ;; Shift one column to the left
         (beginning-of-line)
         (insert-tab)
@@ -463,14 +450,9 @@ output in a compilation buffer."
     (if (bobp)
         0
       (progn
-        (while (and (coffee-line-empty-p) (not (bobp))) (forward-line -1))
+        (while (and (looking-at "^[ \t]*$") (not (bobp))) (forward-line -1))
         (current-indentation)))))
 
-(defun coffee-line-empty-p ()
-  "Is this line empty? Returns non-nil if so, nil if not."
-  (or (bobp)
-   (string-match "^\\s *$" (coffee-line-as-string))))
-
 (defun coffee-newline-and-indent ()
   "Insert a newline and indent it to the same level as the previous line."
   (interactive)