[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/jade-mode 63561e36f7 006/128: functional line indentation
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/jade-mode 63561e36f7 006/128: functional line indentation logic |
Date: |
Sat, 29 Jan 2022 08:24:41 -0500 (EST) |
branch: elpa/jade-mode
commit 63561e36f7a9b5b0887932feed04d459afe3e6b9
Author: brianc <brian.m.carlson@gmail.com>
Commit: brianc <brian.m.carlson@gmail.com>
functional line indentation logic
---
jade-mode.el | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/jade-mode.el b/jade-mode.el
index 381a3d3a51..3230324ddd 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -7,6 +7,10 @@
"Prints a debug message"
(apply 'message (append (list string) args)))
+(defmacro jade-line-as-string ()
+ "Returns the current line as a string."
+ `(buffer-substring (point-at-bol) (point-at-eol)))
+
(defun jade-indent-line ()
"Indents current line")
@@ -22,15 +26,29 @@
;; should only indent if previous line is indented at most one less
(> (jade-previous-indentation) (- (current-indentation) 1)))
+(defun jade-empty-line-p ()
+ "If line is empty or not."
+ (= (point-at-eol) (point-at-bol)))
+
(defun jade-indent-line ()
"Indents the line."
(interactive)
- (if (jade-should-indent-p)
- (save-excursion
- (let ((ci (current-indentation)))
- (beginning-of-line)
- (delete-horizontal-space)
- (indent-to (+ jade-tab-width ci))))))
+
+ ;; indent straight to end on empty line
+ (if (jade-empty-line-p)
+ (indent-to (jade-previous-indentation))
+ (if (jade-should-indent-p)
+ (progn
+ (save-excursion
+ (let ((ci (current-indentation)))
+ (beginning-of-line)
+ (delete-horizontal-space)
+ (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))
+ (move-end-of-line 1)))
(setq jade-font-lock-keywords
`((,"!!!\\( \\(default\\|5\\|transitional\\)\\)?" 0
font-lock-constant-face) ;; doctype
- [nongnu] branch elpa/jade-mode created (now 1ad7c51f3c), ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 7a36edb480 002/128: added readme, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 63561e36f7 006/128: functional line indentation logic,
ELPA Syncer <=
- [nongnu] elpa/jade-mode f8b5b062a0 005/128: started work on electric tab, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 684a5c0fba 014/128: require whitespace-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 63f6e54b85 013/128: define backtab for ubuntu, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode c6623ac6a6 021/128: added a basic stylus-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 039b637cee 016/128: new blank line + single tab = full indent, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode b8778ae525 015/128: use builtin for moving point to beginning of text, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode de66308323 004/128: reboot, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode a22d4acd31 001/128: initial commit, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode a7c85da4df 048/128: Added single quoted strings support to stylus mode., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 3db33f4642 050/128: Fixed sws-indent-line not detecting the use of tab indent, ELPA Syncer, 2022/01/29