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

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

[nongnu] elpa/jade-mode d28d1810fa 007/128: basic decrement tab working


From: ELPA Syncer
Subject: [nongnu] elpa/jade-mode d28d1810fa 007/128: basic decrement tab working
Date: Sat, 29 Jan 2022 08:24:41 -0500 (EST)

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

    basic decrement tab working
---
 jade-mode.el | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/jade-mode.el b/jade-mode.el
index 3230324ddd..2593f5358a 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -30,6 +30,10 @@
   "If line is empty or not."
   (= (point-at-eol) (point-at-bol)))
 
+(defun jade-blank-line-p ()
+  "If line contains only spaces."
+  (string-match-p "^[ ]*$" (jade-line-as-string)))
+
 (defun jade-indent-line ()
   "Indents the line."
   (interactive)
@@ -37,19 +41,35 @@
   ;; indent straight to end on empty line
   (if (jade-empty-line-p)
       (indent-to (jade-previous-indentation))
+    ;; otherwise indent if nesting is correct
     (if (jade-should-indent-p)
         (progn
           (save-excursion
             (let ((ci (current-indentation)))
               (beginning-of-line)
               (delete-horizontal-space)
-              (indent-to (+ jade-tab-width ci))))
-          )))
+              (indent-to (+ jade-tab-width ci)))))))
   ;; move point to end of line on empty lines to make tabbing
   ;; more obvious
-  (if (string-match-p "^[ ]*$" (jade-line-as-string))
+  (if (jade-blank-line-p)
       (move-end-of-line 1)))
 
+(defun jade-max-indent ()
+  "Max indents previous line."
+  (indent-to (+ jade-tab-width (jade-previous-indentation))))
+
+(defun jade-unindent-line ()
+  "Unindents the current line"
+  (interactive)
+  (let ((ci (current-indentation)))
+    (if (= ci 0)
+        ;; no indentation, set to max
+        (jade-max-indent)
+      (progn
+        (beginning-of-line)
+        (delete-horizontal-space)
+        (indent-to (- ci jade-tab-width))))))
+
 (setq jade-font-lock-keywords
       `((,"!!!\\( \\(default\\|5\\|transitional\\)\\)?" 0 
font-lock-constant-face) ;; doctype
         (,"#\\(\\w\\|_\\|-\\)*" . font-lock-type-face) ;; id



reply via email to

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