summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/lisp-mode.el
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2018-07-27 19:41:39 -0400
committerNoam Postavsky <npostavs@gmail.com>2018-07-27 19:41:39 -0400
commit857910539313c0f2d89fe5626a41f1abe6c33ca7 (patch)
tree7c4a9b8184cd09d842962fe9dcbec07651611766 /lisp/emacs-lisp/lisp-mode.el
parentd24c5f26bf6c12bda614f90ba3345d710482005a (diff)
downloademacs-857910539313c0f2d89fe5626a41f1abe6c33ca7.tar.gz
emacs-857910539313c0f2d89fe5626a41f1abe6c33ca7.tar.bz2
emacs-857910539313c0f2d89fe5626a41f1abe6c33ca7.zip
Don't fail to indent-sexp before a full sexp (Bug#31984)
* lisp/emacs-lisp/lisp-mode.el (indent-sexp): Only signal error if the initial forward-sexp fails. Suppress scan-error forn any of the forward-sexp calls after that. * test/lisp/emacs-lisp/lisp-mode-tests.el (indent-sexp-cant-go): New test.
Diffstat (limited to 'lisp/emacs-lisp/lisp-mode.el')
-rw-r--r--lisp/emacs-lisp/lisp-mode.el24
1 files changed, 16 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 44b27236a9c..205c810b978 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1199,14 +1199,22 @@ ENDPOS is encountered."
(setq endpos (copy-marker
(if endpos endpos
;; Get error now if we don't have a complete sexp
- ;; after point. 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.
- (let ((eol (line-end-position)))
- (save-excursion (while (and (< (point) eol) (not (eobp)))
- (forward-sexp 1))
- (point))))))
+ ;; after point.
+ (save-excursion
+ (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)))
+ (point)))))
(save-excursion
(while (let ((indent (lisp-indent-calc-next parse-state))
(ppss (lisp-indent-state-ppss parse-state)))