summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2019-04-15 18:49:57 -0400
committerNoam Postavsky <npostavs@gmail.com>2019-04-22 12:49:36 -0400
commit93912baefd10ccb3e6e2e9696cda3b813c056c87 (patch)
tree0b0557ff122a4fe6138ab564bd5ada5d73876b10 /test
parent3988e93d4b0f2bf677efd9f560373dd526097609 (diff)
downloademacs-93912baefd10ccb3e6e2e9696cda3b813c056c87.tar.gz
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
(indent-sexp)
(should (equal (buffer-string) "(())"))))
+(ert-deftest indent-sexp-stop-before-eol-comment ()
+ "`indent-sexp' shouldn't look for more sexps after an eol comment."
+ ;; See https://debbugs.gnu.org/35286.
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (let ((str "() ;;\n x"))
+ (insert str)
+ (goto-char (point-min))
+ (indent-sexp)
+ ;; The "x" is in the next sexp, so it shouldn't get indented.
+ (should (equal (buffer-string) str)))))
+
+(ert-deftest indent-sexp-stop-before-eol-non-lisp ()
+ "`indent-sexp' shouldn't be too agressive in non-Lisp modes."
+ ;; See https://debbugs.gnu.org/35286#13.
+ (with-temp-buffer
+ (prolog-mode)
+ (let ((str "\
+x(H) -->
+ {y(H)}.
+a(A) -->
+ b(A)."))
+ (insert str)
+ (search-backward "{")
+ (indent-sexp)
+ ;; There's no line-spanning sexp, so nothing should be indented.
+ (should (equal (buffer-string) str)))))
+
(ert-deftest lisp-indent-region ()
"Test basics of `lisp-indent-region'."
(with-temp-buffer