summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wanstrath <chris@ozmm.org>2010-03-07 00:59:47 -0800
committerChris Wanstrath <chris@ozmm.org>2010-03-07 00:59:47 -0800
commitf92b25d78940fdce70d2b282a0514a1650e48eed (patch)
tree85dcb4a6125ee21dbaddd70712ce0c94ac6ffe48
parent8bfb7ed6162a5cef9acdd76e8dfddef352336de3 (diff)
downloademacs-f92b25d78940fdce70d2b282a0514a1650e48eed.tar.gz
explain the new awesome newline-then-indent style
-rw-r--r--coffee-mode.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/coffee-mode.el b/coffee-mode.el
index 9c6e95f934a..86141deaecf 100644
--- a/coffee-mode.el
+++ b/coffee-mode.el
@@ -239,6 +239,25 @@ For detail, see `comment-dwim'."
;; ^
;;
;; And so on.
+;;
+;; As for indentation after newlines, given this code:
+;;
+;; line1()
+;; line2()
+;; line3()
+;; ^
+;; Pressing RET would insert a newline and place our cursor at the
+;; following position:
+;;
+;; line1()
+;; line2()
+;; line3()
+;;
+;; ^
+;;
+;; In other words, the level of indentation is maintained. This
+;; applies to comments as well.
+
(defun coffee-indent-line ()
"Indent current line as CoffeeScript"
@@ -267,6 +286,9 @@ For detail, see `comment-dwim'."
"Inserts a newline and indents it to the same level as the previous line."
(interactive)
+ ;; Remember the current line indentation level,
+ ;; insert a newline, and indent the newline to the same
+ ;; level as the previous line.
(let ((prev-indent (current-indentation)))
(newline)
(insert-tab (/ prev-indent tab-width)))