Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Simplify coffee-indent-line and coffee-previous-indent.

As a result, remove coffee-line-as-string and coffee-line-empty-p.
  • Loading branch information...
commit 3f4271f084959bb825754600441fee1bac677268 1 parent 579e270
Reuben Thomas rrthomas authored

Showing 1 changed file with 3 additions and 21 deletions. Show diff stats Hide diff stats

  1. +3 21 coffee-mode.el
24 coffee-mode.el
@@ -124,14 +124,6 @@ with CoffeeScript."
124 124 "Keymap for CoffeeScript major mode.")
125 125
126 126 ;;
127   -;; Macros
128   -;;
129   -
130   -(defmacro coffee-line-as-string ()
131   - "Returns the current line as a string."
132   - `(buffer-substring (point-at-bol) (point-at-eol)))
133   -
134   -;;
135 127 ;; Commands
136 128 ;;
137 129
@@ -437,13 +429,8 @@ output in a compilation buffer."
437 429 (if (= (point) (point-at-bol))
438 430 (insert-tab)
439 431 (save-excursion
440   - (let ((prev-indent 0) (cur-indent 0))
441   - ;; Figure out the indentation of the previous line
442   - (setq prev-indent (coffee-previous-indent))
443   -
444   - ;; Figure out the current line's indentation
445   - (setq cur-indent (current-indentation))
446   -
  432 + (let ((prev-indent (coffee-previous-indent))
  433 + (cur-indent (current-indentation)))
447 434 ;; Shift one column to the left
448 435 (beginning-of-line)
449 436 (insert-tab)
@@ -463,14 +450,9 @@ output in a compilation buffer."
463 450 (if (bobp)
464 451 0
465 452 (progn
466   - (while (and (coffee-line-empty-p) (not (bobp))) (forward-line -1))
  453 + (while (and (looking-at "^[ \t]*$") (not (bobp))) (forward-line -1))
467 454 (current-indentation)))))
468 455
469   -(defun coffee-line-empty-p ()
470   - "Is this line empty? Returns non-nil if so, nil if not."
471   - (or (bobp)
472   - (string-match "^\\s *$" (coffee-line-as-string))))
473   -
474 456 (defun coffee-newline-and-indent ()
475 457 "Insert a newline and indent it to the same level as the previous line."
476 458 (interactive)

0 comments on commit 3f4271f

Please sign in to comment.
Something went wrong with that request. Please try again.