From: Noam Postavsky <npostavs@gmail.com>
To: Gemini Lasswell <gazally@runbox.com>
Cc: 31984@debbugs.gnu.org
Subject: bug#31984: 26.1.50; IELM doesn't indent results printed with #
Date: Thu, 19 Jul 2018 07:16:52 -0400 [thread overview]
Message-ID: <87h8kv79wb.fsf@gmail.com> (raw)
In-Reply-To: <87muvfoeip.fsf@gmail.com> (Noam Postavsky's message of "Wed, 27 Jun 2018 22:01:34 -0400")
[-- Attachment #1: Type: text/plain, Size: 680 bytes --]
tags 31984 + patch
quit
Noam Postavsky <npostavs@gmail.com> writes:
> With point before the (foo), Emacs 25 indent-sexp turns this
>
> (foo) (blah
> etc)
>
> into this
>
> (foo) (blah
> etc)
>
> Emacs 26 indent-sexp doesn't do anything from that position. It's less
> clear which is correct in that case, but restoring to the Emacs 25
> behaviour would fix the #s(...) case as well. Alternatively, we could
> fix elisp sexp movement to handle such expressions, which we should
> probably do anyway (see also Bug#15998).
Probably Bug#15998 won't be fixed in Emacs 26, so here's a patch to make
indent-sexp indent the sexp spanning the end of line, like Emacs 25
does.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2506 bytes --]
From 3e206ed6c2c82ef3d147b3dece6dc65ffe1625a2 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Thu, 19 Jul 2018 06:40:54 -0400
Subject: [PATCH] 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 3a03b56313..44b27236a9 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1199,8 +1199,14 @@ indent-sexp
(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 8598d41978..0b052e9fc3 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -113,6 +113,18 @@ lisp-mode-tests--correctly-indented-sexp
;; 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
--
2.11.0
next prev parent reply other threads:[~2018-07-19 11:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 19:42 bug#31984: 26.1.50; IELM doesn't indent results printed with # Gemini Lasswell
2018-06-28 2:01 ` Noam Postavsky
2018-07-19 11:16 ` Noam Postavsky [this message]
2018-07-19 19:01 ` Gemini Lasswell
2018-07-22 1:30 ` Noam Postavsky
2018-07-26 11:49 ` Davor Rotim
2018-07-28 0:15 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h8kv79wb.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=31984@debbugs.gnu.org \
--cc=gazally@runbox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).