emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/jade-mode f8b5b062a0 005/128: started work on electric tab


From: ELPA Syncer
Subject: [nongnu] elpa/jade-mode f8b5b062a0 005/128: started work on electric tab
Date: Sat, 29 Jan 2022 08:24:41 -0500 (EST)

branch: elpa/jade-mode
commit f8b5b062a03356508b2dd7f3ef486f554301824b
Author: brianc <brian.m.carlson@gmail.com>
Commit: brianc <brian.m.carlson@gmail.com>

    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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]