bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#26891: 26.0.50; Error using lisp-indent-line in eval-expression mini


From: npostavs
Subject: bug#26891: 26.0.50; Error using lisp-indent-line in eval-expression minibuffer
Date: Thu, 11 May 2017 21:11:37 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

tags 26891 patch
quit

John Mastro <john.b.mastro@gmail.com> writes:

> Using lisp-indent-line in an eval-expression minibuffer (i.e. M-:) works
> in Emacs 25 but causes a "Text is read-only" error in Emacs 26.
>
> To reproduce:
> 1. Run emacs -Q
> 2. Evaluate the code below
> 3. Type M-:
> 4. Hit TAB
>
> Here's the code:
>
>     (defun init-eval-expression-minibuffer ()
>       (setq-local indent-line-function #'lisp-indent-line)
>       (local-set-key (kbd "TAB") #'indent-for-tab-command))
>
>     (add-hook 'eval-expression-minibuffer-setup-hook
>               #'init-eval-expression-minibuffer)
>
> Point will move to the very beginning of the minibuffer (on the "E" in
> "Eval") and you'll see a "Text is read only" message. (I called it an
> error above but it doesn't actually invoke the debugger even with
> debug-on-error and debug-on-signal non-nil).
>
> It doesn't matter whether you have entered text or not before hitting
> TAB.

indent-line-to doesn't respect field boundaries (i.e., moves into the
"Eval: " prompt text) because it uses backward-to-indentation.  This
patch to change it to back-to-indentation seems to fix it.  I'm not sure
why back-to-indentation and backward-to-indentation are inconsistent...

>From 33880d67f0cc567ca5c317f828cc15859dcd9fe7 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Thu, 11 May 2017 21:06:33 -0400
Subject: [PATCH v1] Make `indent-indent-to' respect field boundaries
 (Bug#26891)

* lisp/indent.el (indent-line-to): Use `back-to-indentation' instead
of `backward-to-indentation'.
---
 lisp/indent.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/indent.el b/lisp/indent.el
index fdd184c799..e7a30b885d 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -285,7 +285,7 @@ indent-line-to
   "Indent current line to COLUMN.
 This function removes or adds spaces and tabs at beginning of line
 only if necessary.  It leaves point at end of indentation."
-  (backward-to-indentation 0)
+  (back-to-indentation)
   (let ((cur-col (current-column)))
     (cond ((< cur-col column)
           (if (>= (- column (* (/ cur-col tab-width) tab-width)) tab-width)
-- 
2.11.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]