[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 1b4b965 2/3: Fix indent-sexp of #s(...) (Bug#3198
From: |
Noam Postavsky |
Subject: |
[Emacs-diffs] emacs-26 1b4b965 2/3: Fix indent-sexp of #s(...) (Bug#31984) |
Date: |
Sat, 21 Jul 2018 21:28:55 -0400 (EDT) |
branch: emacs-26
commit 1b4b96597c7868d9c24389d83089097a521206a5
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Fix indent-sexp of #s(...) (Bug#31984)
* lisp/emacs-lisp/lisp-mode.el (indent-sexp): Look for a sexp that
ends after the current line.
* test/lisp/emacs-lisp/lisp-mode-tests.el (indent-sexp-go): New test.
---
lisp/emacs-lisp/lisp-mode.el | 10 ++++++++--
test/lisp/emacs-lisp/lisp-mode-tests.el | 12 ++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 3a03b56..44b2723 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1199,8 +1199,14 @@ ENDPOS is encountered."
(setq endpos (copy-marker
(if endpos endpos
;; Get error now if we don't have a complete sexp
- ;; after point.
- (save-excursion (forward-sexp 1) (point)))))
+ ;; 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))))))
(save-excursion
(while (let ((indent (lisp-indent-calc-next parse-state))
(ppss (lisp-indent-state-ppss parse-state)))
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el
b/test/lisp/emacs-lisp/lisp-mode-tests.el
index 8598d41..0b052e9 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -113,6 +113,18 @@ noindent\" 3
;; we're indenting ends on the previous line.
(should (equal (buffer-string) original)))))
+(ert-deftest indent-sexp-go ()
+ "Make sure `indent-sexp' doesn't stop after #s."
+ ;; See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=31984.
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "#s(foo\nbar)\n")
+ (goto-char (point-min))
+ (indent-sexp)
+ (should (equal (buffer-string) "\
+#s(foo
+ bar)\n"))))
+
(ert-deftest lisp-indent-region ()
"Test basics of `lisp-indent-region'."
(with-temp-buffer