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

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

[nongnu] elpa/jade-mode efb86f6a36 101/128: Merge pull request #51 from


From: ELPA Syncer
Subject: [nongnu] elpa/jade-mode efb86f6a36 101/128: Merge pull request #51 from tjefferson08/fix_compile_warnings
Date: Sat, 29 Jan 2022 08:24:51 -0500 (EST)

branch: elpa/jade-mode
commit efb86f6a36c0338e934cf543a8742b0154ccc0e0
Merge: c4014d8a9c 279df56bf9
Author: Travis Jefferson <tjefferson@signpost.com>
Commit: Travis Jefferson <tjefferson@signpost.com>

    Merge pull request #51 from tjefferson08/fix_compile_warnings
    
    Fix compile warnings and strengthen indentation
---
 Makefile             |  2 +-
 jade-mode.el         | 18 ++++++++++++++++--
 tests/indentation.el | 26 ++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index fef3a67f98..6ba9019f9d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
 test:
-       emacs -batch -L . -l ./tests/highlight.el -f 
ert-run-tests-batch-and-exit
+       emacs -batch -L . -l ./tests/highlight.el -l ./tests/indentation.el -f 
ert-run-tests-batch-and-exit
 # Local Variables:
 # indent-tabs-mode: t
diff --git a/jade-mode.el b/jade-mode.el
index 43bc12730d..16d6fbccc7 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -6,6 +6,8 @@
 (require 'font-lock)
 (require 'js)
 
+(defvar jade-tab-width)
+
 (defun jade-debug (string &rest args)
   "Prints a debug message"
   (apply 'message (append (list string) args)))
@@ -187,8 +189,8 @@ declaration"
   (beginning-of-line)
   (let ((ci (current-indentation)))
     (push-mark nil nil t)
-    (while (> (jade-next-line-indent) ci)
-      (next-line)
+    (while (> (jade-next-line-indentation) ci)
+      (forward-line)
       (end-of-line))))
 
 (defun jade-indent ()
@@ -307,6 +309,18 @@ Follows indentation behavior of `indent-rigidly'."
     (let ((prev-line-indent (current-indentation)))
       prev-line-indent)))
 
+(defun jade-next-line-indentation ()
+  "Get the indentation of the next (non-blank) line (from point)."
+  (interactive)
+  (save-excursion
+
+    ;; move down to the next non-blank line (or buffer end)
+    (while (progn ;; progn used to get do...while control flow
+             (forward-line 1)
+             (and (jade-blank-line-p) (not (= (point-at-eol) (point-max))))))
+    (let ((next-line-indent (current-indentation)))
+      next-line-indent)))
+
 (defun jade-newline-and-indent ()
   "Insert newline and indent to parent's indentation level."
   (interactive)
diff --git a/tests/indentation.el b/tests/indentation.el
new file mode 100644
index 0000000000..43ff0ee075
--- /dev/null
+++ b/tests/indentation.el
@@ -0,0 +1,26 @@
+(require 'ert)
+(require 'jade-mode)
+
+(ert-deftest jade-mode-get-line-indentations ()
+  (with-temp-buffer
+    (insert "doctype html\nhtml\n  body\n    div\n      p content inside 
body\n")
+    (jade-mode)
+
+    ;; go to <div> line (at d of div)
+    (goto-char 30)
+    (should (looking-at "d"))
+    (should (= (current-indentation) 4))
+    (should (= (jade-next-line-indentation) 6))
+    (should (= (jade-previous-line-indentation) 2))
+
+    (beginning-of-line)
+    (should (looking-at "^"))
+    (should (= (current-indentation) 4))
+    (should (= (jade-next-line-indentation) 6))
+    (should (= (jade-previous-line-indentation) 2))
+
+    (end-of-line)
+    (should (looking-at "$"))
+    (should (= (current-indentation) 4))
+    (should (= (jade-next-line-indentation) 6))
+    (should (= (jade-previous-line-indentation) 2))))



reply via email to

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