diff options
author | Noam Postavsky <npostavs@gmail.com> | 2019-04-15 18:49:57 -0400 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2019-04-22 12:49:36 -0400 |
commit | 93912baefd10ccb3e6e2e9696cda3b813c056c87 (patch) | |
tree | 0b0557ff122a4fe6138ab564bd5ada5d73876b10 /test/lisp | |
parent | 3988e93d4b0f2bf677efd9f560373dd526097609 (diff) | |
download | emacs-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/lisp')
-rw-r--r-- | test/lisp/emacs-lisp/lisp-mode-tests.el | 28 |
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 |