Subject: Re: bug#26891: 26.0.50; Error using lisp-indent-line in eval-expression minibuffer

From: [email-masked]
Date: Thu, 11 May 2017 21:11:37 -0400

tags 26891 patch
quit

John Mastro <[email-masked]> 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 <[email-masked]>
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