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 /lisp/emacs-lisp/lisp-mode.el | |
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 'lisp/emacs-lisp/lisp-mode.el')
-rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 57f57175c51..74bf0c87c53 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -1205,19 +1205,25 @@ ENDPOS is encountered." ;; Get error now if we don't have a complete sexp ;; after point. (save-excursion + (forward-sexp 1) (let ((eol (line-end-position))) - (forward-sexp 1) ;; We actually look for a sexp which ends ;; after the current line so that we properly ;; indent things like #s(...). This might not ;; be needed if Bug#15998 is fixed. - (condition-case () - (while (and (< (point) eol) (not (eobp))) - (forward-sexp 1)) - ;; But don't signal an error for incomplete - ;; sexps following the first complete sexp - ;; after point. - (scan-error nil))) + (when (and (< (point) eol) + ;; Check if eol is within a sexp. + (> (nth 0 (save-excursion + (parse-partial-sexp + (point) eol))) + 0)) + (condition-case () + (while (< (point) eol) + (forward-sexp 1)) + ;; But don't signal an error for incomplete + ;; sexps following the first complete sexp + ;; after point. + (scan-error nil)))) (point))))) (save-excursion (while (let ((indent (lisp-indent-calc-next parse-state)) |