From: Noam Postavsky <npostavs@gmail.com>
To: "João Távora" <joaotavora@gmail.com>
Cc: 32014@debbugs.gnu.org
Subject: bug#32014: 26.1; lisp-indent-line fails in first line of Ielm
Date: Fri, 29 Jun 2018 20:23:13 -0400 [thread overview]
Message-ID: <87sh55m8b2.fsf@gmail.com> (raw)
In-Reply-To: <876021mb84.fsf@gmail.com> ("João Távora"'s message of "Sat, 30 Jun 2018 00:20:11 +0100")
[-- Attachment #1: Type: text/plain, Size: 1243 bytes --]
tags 32014 + patch
quit
João Távora <joaotavora@gmail.com> writes:
> The error's backtrace isn't shown even with debug-on-error set to t.
If you (setq debug-ignored-errors nil) first, then the backtrace is
Debugger entered--Lisp error: (text-read-only)
indent-line-to(7)
lisp-indent-line()
funcall-interactively(lisp-indent-line)
call-interactively(lisp-indent-line record nil)
command-execute(lisp-indent-line record)
execute-extended-command(nil "lisp-indent-line" "lisp-indent-line")
funcall-interactively(execute-extended-command nil "lisp-indent-line" "lisp-indent-line")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
> Is this the intended behaviour? In 25.2 the string foo was correctly
> indented back one character, so this seems like a regression.
No, it's an accident. In lisp-indent-line, I simplified
(setq shift-amt (- indent (current-column)))
(if (zerop shift-amt)
nil
(delete-region beg (point))
(indent-to indent)))
into
(indent-line-to indent)
but it turns out not be equivalent in this case. indent-line-to doesn't
respect the prompt's field property.
I propose this for emacs-26:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1222 bytes --]
From 2524780c54bcd8faecdb8497c0e1c960752fc9ce Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Fri, 29 Jun 2018 20:15:10 -0400
Subject: [PATCH v1 1/2] ; Test for Bug#32014
* test/lisp/emacs-lisp/lisp-mode-tests.el
(lisp-indent-with-read-only-field): New test.
---
test/lisp/emacs-lisp/lisp-mode-tests.el | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el
index 0b5b0a4019..2ac0e5ce1d 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -224,6 +224,17 @@ lisp-mode-tests--correctly-indented-sexp
(comment-indent)
(should (equal (buffer-string) correct)))))
+(ert-deftest lisp-indent-with-read-only-field ()
+ "Test indentation on line with read-only field (Bug#32014)."
+ :expected-result :failed
+ (with-temp-buffer
+ (insert (propertize "prompt> " 'field 'output 'read-only t
+ 'rear-nonsticky t 'front-sticky '(read-only)))
+ (insert " foo")
+ (lisp-indent-line)
+ (should (equal (buffer-string) "prompt> foo"))))
+
+
(provide 'lisp-mode-tests)
;;; lisp-mode-tests.el ends here
--
2.11.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: patch --]
[-- Type: text/x-diff, Size: 2590 bytes --]
From 98e30ee9505f6e8cd21a36b88223e29ad9ee8281 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Fri, 29 Jun 2018 19:58:58 -0400
Subject: [PATCH v1 2/2] Stop using indent-line-to in lisp-indent-line
(Bug#32014)
This is partial revert of "Remove ignored argument from
lisp-indent-line", because `indent-line-to' doesn't respect field
boundaries.
* lisp/emacs-lisp/lisp-mode.el (lisp-indent-line): Use delete-region
and indent-to instead of `indent-line-to'.
* test/lisp/emacs-lisp/lisp-mode-tests.el
(lisp-indent-with-read-only-field): Expect to pass.
Don't merge to master, we will fix indent-line-to there instead.
---
lisp/emacs-lisp/lisp-mode.el | 10 ++++++++--
test/lisp/emacs-lisp/lisp-mode-tests.el | 1 -
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 94be5acd6d..3a03b56313 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -867,7 +867,9 @@ lisp-indent-line
(interactive)
(let ((pos (- (point-max) (point)))
(indent (progn (beginning-of-line)
- (or indent (calculate-lisp-indent (lisp-ppss))))))
+ (or indent (calculate-lisp-indent (lisp-ppss)))))
+ (shift-amt nil)
+ (beg (progn (beginning-of-line) (point))))
(skip-chars-forward " \t")
(if (or (null indent) (looking-at "\\s<\\s<\\s<"))
;; Don't alter indentation of a ;;; comment line
@@ -879,7 +881,11 @@ lisp-indent-line
;; as comment lines, not as code.
(progn (indent-for-comment) (forward-char -1))
(if (listp indent) (setq indent (car indent)))
- (indent-line-to indent))
+ (setq shift-amt (- indent (current-column)))
+ (if (zerop shift-amt)
+ nil
+ (delete-region beg (point))
+ (indent-to indent)))
;; If initial point was within line's indentation,
;; position after the indentation. Else stay at same point in text.
(if (> (- (point-max) pos) (point))
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el
index 2ac0e5ce1d..8598d41978 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -226,7 +226,6 @@ lisp-mode-tests--correctly-indented-sexp
(ert-deftest lisp-indent-with-read-only-field ()
"Test indentation on line with read-only field (Bug#32014)."
- :expected-result :failed
(with-temp-buffer
(insert (propertize "prompt> " 'field 'output 'read-only t
'rear-nonsticky t 'front-sticky '(read-only)))
--
2.11.0
[-- Attachment #4: Type: text/plain, Size: 23 bytes --]
and this for master:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: patch --]
[-- Type: text/x-diff, Size: 1173 bytes --]
From 2dccc6d64669078915a7eda75f40e75408b7794e Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Fri, 29 Jun 2018 20:01:53 -0400
Subject: [PATCH] Respect field boundaries in *-to-indentation functions
(Bug#32014)
* lisp/simple.el (forward-to-indentation)
(backward-to-indentation): Use `beginning-of-line' which respects
field boundaries rather than `forward-line' which doesn't.
---
lisp/simple.el | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index f8c02c1dbf..3cece52657 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -872,13 +872,13 @@ quoted-insert
(defun forward-to-indentation (&optional arg)
"Move forward ARG lines and position at first nonblank character."
(interactive "^p")
- (forward-line (or arg 1))
+ (beginning-of-line (+ 1 (or arg 1)))
(skip-chars-forward " \t"))
(defun backward-to-indentation (&optional arg)
"Move backward ARG lines and position at first nonblank character."
(interactive "^p")
- (forward-line (- (or arg 1)))
+ (beginning-of-line (- 1 (or arg 1)))
(skip-chars-forward " \t"))
(defun back-to-indentation ()
--
2.11.0
next prev parent reply other threads:[~2018-06-30 0:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-29 23:20 bug#32014: 26.1; lisp-indent-line fails in first line of Ielm João Távora
2018-06-30 0:23 ` Noam Postavsky [this message]
2018-06-30 6:52 ` Eli Zaretskii
2018-06-30 13:27 ` Noam Postavsky
2018-07-10 0:48 ` Noam Postavsky
2018-07-10 7:04 ` João Távora
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sh55m8b2.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=32014@debbugs.gnu.org \
--cc=joaotavora@gmail.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.