branch: elpa/jade-mode
commit f8b5b062a03356508b2dd7f3ef486f554301824b
Author: brianc <[email protected]>
Commit: brianc <[email protected]>
started work on electric tab
---
jade-mode.el | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/jade-mode.el b/jade-mode.el
index ea54274dff..381a3d3a51 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -11,10 +11,26 @@
(defun jade-indent-line ()
"Indents current line")
+(defun jade-previous-indentation ()
+ "Gets indentation for previous line"
+ (save-excursion
+ (previous-line)
+ (current-indentation)))
+
+(defun jade-should-indent-p ()
+ "Whether or not line should be indented."
+ ;; should only indent if previous line is indented at most one less
+ (> (jade-previous-indentation) (- (current-indentation) 1)))
+
(defun jade-indent-line ()
"Indents the line."
(interactive)
- (jade-debug "TODO: implement this"))
+ (if (jade-should-indent-p)
+ (save-excursion
+ (let ((ci (current-indentation)))
+ (beginning-of-line)
+ (delete-horizontal-space)
+ (indent-to (+ jade-tab-width ci))))))
(setq jade-font-lock-keywords
`((,"!!!\\( \\(default\\|5\\|transitional\\)\\)?" 0
font-lock-constant-face) ;; doctype