aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky2019-04-15 18:49:57 -0400
committerNoam Postavsky2019-04-22 12:49:36 -0400
commit93912baefd10ccb3e6e2e9696cda3b813c056c87 (patch)
tree0b0557ff122a4fe6138ab564bd5ada5d73876b10 /test
parent3988e93d4b0f2bf677efd9f560373dd526097609 (diff)
downloademacs-93912baefd10ccb3e6e2e9696cda3b813c056c87.tar.gz
emacs-93912baefd10ccb3e6e2e9696cda3b813c056c87.zip
Be more careful about indent-sexp going over eol (Bug#35286)
* lisp/emacs-lisp/lisp-mode.el (indent-sexp): Only go over multiple sexps if the end of line is within a sexp. * test/lisp/emacs-lisp/lisp-mode-tests.el (indent-sexp-stop-before-eol-comment) (indent-sexp-stop-before-eol-non-lisp): New tests.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/lisp-mode-tests.el28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el
index a6370742ab4..63632449ca5 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -136,6 +136,34 @@ noindent\" 3
136 (indent-sexp) 136 (indent-sexp)
137 (should (equal (buffer-string) "(())")))) 137 (should (equal (buffer-string) "(())"))))
138 138
139(ert-deftest indent-sexp-stop-before-eol-comment ()
140 "`indent-sexp' shouldn't look for more sexps after an eol comment."
141 ;; See https://debbugs.gnu.org/35286.
142 (with-temp-buffer
143 (emacs-lisp-mode)
144 (let ((str "() ;;\n x"))
145 (insert str)
146 (goto-char (point-min))
147 (indent-sexp)
148 ;; The "x" is in the next sexp, so it shouldn't get indented.
149 (should (equal (buffer-string) str)))))
150
151(ert-deftest indent-sexp-stop-before-eol-non-lisp ()
152 "`indent-sexp' shouldn't be too agressive in non-Lisp modes."
153 ;; See https://debbugs.gnu.org/35286#13.
154 (with-temp-buffer
155 (prolog-mode)
156 (let ((str "\
157x(H) -->
158 {y(H)}.
159a(A) -->
160 b(A)."))
161 (insert str)
162 (search-backward "{")
163 (indent-sexp)
164 ;; There's no line-spanning sexp, so nothing should be indented.
165 (should (equal (buffer-string) str)))))
166
139(ert-deftest lisp-indent-region () 167(ert-deftest lisp-indent-region ()
140 "Test basics of `lisp-indent-region'." 168 "Test basics of `lisp-indent-region'."
141 (with-temp-buffer 169 (with-temp-buffer