GNU bug report logs - #46033
up arrow in query replace should not step into the prompt

Previous Next

Package: emacs;

Reported by: reporter <laszlomail <at> protonmail.com>

Date: Fri, 22 Jan 2021 13:23:02 UTC

Severity: normal

Tags: fixed

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 46033 in the body.
You can then email your comments to 46033 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Fri, 22 Jan 2021 13:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to reporter <laszlomail <at> protonmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 22 Jan 2021 13:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: reporter <laszlomail <at> protonmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: up arrow  in query replace should not step into the prompt
Date: Fri, 22 Jan 2021 13:21:50 +0000
Up/down arrow is useful in the replace prompt, because sometimes
the replace text is long and spans multiple lines, so up/down is
handy to navigate it.

Up arrow can also retrieve previous history lines when you are
already at the top line of the replacement.

However, if there is a multiline replacement default in the
prompt then up arrow steps into the prompt first and only further
presses retrieve history:

https://i.imgur.com/7G3FcPX.png

Up arrow should not lead the user uselessly into the prompt text.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Fri, 22 Jan 2021 13:56:01 GMT) Full text and rfc822 format available.

Message #8 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: reporter <laszlomail <at> protonmail.com>
Cc: 46033 <at> debbugs.gnu.org
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Fri, 22 Jan 2021 15:55:20 +0200
> Date: Fri, 22 Jan 2021 13:21:50 +0000
> From: laszlomail--- via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Up/down arrow is useful in the replace prompt, because sometimes
> the replace text is long and spans multiple lines, so up/down is
> handy to navigate it.
> 
> Up arrow can also retrieve previous history lines when you are
> already at the top line of the replacement.
> 
> However, if there is a multiline replacement default in the
> prompt then up arrow steps into the prompt first and only further
> presses retrieve history:
> 
> https://i.imgur.com/7G3FcPX.png
> 
> Up arrow should not lead the user uselessly into the prompt text.

This is a feature: it allows you to scroll through the text shown in
the minibuffer, in case you want to edit it.  Use M-p to go directly
to the previous history.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Fri, 22 Jan 2021 14:17:01 GMT) Full text and rfc822 format available.

Message #11 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: reporter <laszlomail <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Fri, 22 Jan 2021 14:16:38 +0000
>
> This is a feature: it allows you to scroll through the text shown in
> the minibuffer, in case you want to edit it. Use M-p to go directly
> to the previous history.

I understand it's a feature, but as you see in the picture the prompt is
empty, and the full default replacement is visible.

In this case arrow should retrieve the previous history, instead of going
into the prompt, because there is nothing to scroll.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Fri, 22 Jan 2021 18:46:02 GMT) Full text and rfc822 format available.

Message #14 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: reporter <laszlomail <at> protonmail.com>, 46033 <at> debbugs.gnu.org
Subject: Re: bug#46033: up arrow  in query replace should not step into the
 prompt
Date: Fri, 22 Jan 2021 19:44:52 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

> This is a feature: it allows you to scroll through the text shown in
> the minibuffer, in case you want to edit it.  Use M-p to go directly
> to the previous history.

I think the complaint is that this:

M-: (read-string "Foo: ")
<up>

and this:

M-: (read-string "This is a very long prompt indeed and it goes on and on and never seems to stop oh yes now it did: ")
<up>

work very differently.  In the first case, the <up> works the same as
`M-p',  In the latter case, <up> puts point into the prompt.

It does seem inconsistent.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Fri, 22 Jan 2021 18:53:01 GMT) Full text and rfc822 format available.

Message #17 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: laszlomail <at> protonmail.com, 46033 <at> debbugs.gnu.org
Subject: Re: bug#46033: up arrow  in query replace should not step into the
 prompt
Date: Fri, 22 Jan 2021 20:52:19 +0200
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: reporter <laszlomail <at> protonmail.com>,  46033 <at> debbugs.gnu.org
> Date: Fri, 22 Jan 2021 19:44:52 +0100
> 
> I think the complaint is that this:
> 
> M-: (read-string "Foo: ")
> <up>
> 
> and this:
> 
> M-: (read-string "This is a very long prompt indeed and it goes on and on and never seems to stop oh yes now it did: ")
> <up>
> 
> work very differently.  In the first case, the <up> works the same as
> `M-p',  In the latter case, <up> puts point into the prompt.
> 
> It does seem inconsistent.

That's how it's supposed to work, though.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 17:35:02 GMT) Full text and rfc822 format available.

Message #20 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: laszlomail--- via "Bug reports for GNU Emacs, the Swiss army knife of
 text editors" <bug-gnu-emacs <at> gnu.org>
Cc: reporter <laszlomail <at> protonmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Sat, 23 Jan 2021 19:24:50 +0200
[Message part 1 (text/plain, inline)]
>> This is a feature: it allows you to scroll through the text shown in
>> the minibuffer, in case you want to edit it. Use M-p to go directly
>> to the previous history.
>
> I understand it's a feature, but as you see in the picture the prompt is
> empty, and the full default replacement is visible.
>
> In this case arrow should retrieve the previous history, instead of going
> into the prompt, because there is nothing to scroll.

Thanks for the well justified request.  This patch avoids moving point
to the prompt on the rightful assumption that most of the time the users
would not want to edit read-only text:

[avoid-minibuffer-prompt.patch (text/x-diff, inline)]
diff --git a/lisp/simple.el b/lisp/simple.el
index 0355ac863a..f5fe366f69 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2476,7 +2476,10 @@ previous-line-or-history-element
 			 (current-column)))))
     (condition-case nil
 	(with-no-warnings
-	  (previous-line arg))
+	  (previous-line arg)
+          ;; Avoid moving point to the prompt
+          (when (< (point) (minibuffer-prompt-end))
+            (signal 'beginning-of-buffer nil)))
       (beginning-of-buffer
        ;; Restore old position since `line-move-visual' moves point to
        ;; the beginning of the line when it fails to go to the previous line.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 17:35:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 17:37:02 GMT) Full text and rfc822 format available.

Message #26 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: reporter <laszlomail <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,
 "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Sat, 23 Jan 2021 17:35:59 +0000
>
> That's how it's supposed to work, though.

It is not useful at all when the prompt is empty and the full default
replacement is visible, because then there is nothing to scroll.

This is the case just after the user invoked query replace. If
the user does not type anything for a new replacement then he
wants to retrieve a previous replacement.

In this specific case up arrow should also retrieve the previous
history, instead of going into the prompt which is useless in
this case.

https://i.imgur.com/7G3FcPX.png





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 17:47:02 GMT) Full text and rfc822 format available.

Message #29 received at submit <at> debbugs.gnu.org (full text, mbox):

From: reporter <laszlomail <at> protonmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: "laszlomail--- via \"Bug reports for GNU Emacs,
 the Swiss army knife of text editors\"" <bug-gnu-emacs <at> gnu.org>,
 Eli Zaretskii <eliz <at> gnu.org>, "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Sat, 23 Jan 2021 17:46:18 +0000
[Message part 1 (text/plain, inline)]
>
> Thanks for the well justified request. This patch avoids moving point
> to the prompt on the rightful assumption that most of the time the users
> would not want to edit read-only text:

This breaks the history retrieval feature with up arrow.

With the current implementation up arrow takes you into the prompt, but if
you are in the top line of the prompt and press up arrow again then up
arrow retrieves history.

In the case I described going into the prompt is useless, so up arrow
should retrieve history immediately, without having to go to the top
line of the prompt first.
[avoid-minibuffer-prompt.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 17:47:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 18:18:01 GMT) Full text and rfc822 format available.

Message #35 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: reporter <laszlomail <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,
 "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Sat, 23 Jan 2021 18:17:22 +0000
[Message part 1 (text/plain, inline)]
>
> In this specific case up arrow should also retrieve the previous
> history, instead of going into the prompt which is useless in
> this case.
>

Attached a patch doing what I propose.
[prompt.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 18:31:02 GMT) Full text and rfc822 format available.

Message #38 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: reporter <laszlomail <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,
 "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Sat, 23 Jan 2021 18:30:33 +0000
[Message part 1 (text/plain, inline)]
>
> Attached a patch doing what I propose.


Fixed typo (using window-start).

[prompt.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 18:34:02 GMT) Full text and rfc822 format available.

Message #41 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: reporter <laszlomail <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,
 "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Sat, 23 Jan 2021 18:33:17 +0000
[Message part 1 (text/plain, inline)]
> > Attached a patch doing what I propose.
>
> Fixed typo (using window-start).


Third time's a charm.
[prompt.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 18:42:01 GMT) Full text and rfc822 format available.

Message #44 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: reporter <laszlomail <at> protonmail.com>
Cc: "laszlomail--- via \"Bug reports for GNU Emacs,  the Swiss army knife of
 text editors\"" <bug-gnu-emacs <at> gnu.org>, Eli Zaretskii <eliz <at> gnu.org>,
 "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Sat, 23 Jan 2021 20:34:34 +0200
>> This patch avoids moving point to the prompt on the rightful
>> assumption that most of the time the users would not want to edit
>> read-only text:
>
> This breaks the history retrieval feature with up arrow.
>
> With the current implementation up arrow takes you into the prompt, but if
> you are in the top line of the prompt and press up arrow again then up
> arrow retrieves history.
>
> In the case I described going into the prompt is useless, so up arrow
> should retrieve history immediately, without having to go to the top
> line of the prompt first.

This is exactly what the patch does.  Have you really tried it?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 18:42:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 18:54:02 GMT) Full text and rfc822 format available.

Message #50 received at submit <at> debbugs.gnu.org (full text, mbox):

From: reporter <laszlomail <at> protonmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: "laszlomail--- via \"Bug reports for GNU Emacs,
 the Swiss army knife of text editors\"" <bug-gnu-emacs <at> gnu.org>,
 Eli Zaretskii <eliz <at> gnu.org>, "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Sat, 23 Jan 2021 18:53:02 +0000
>
> This is exactly what the patch does. Have you really tried it?

Yes, I don't know what happened (I applied it manually), but I
must have made an error, because it didn't work.

Then I checked the original code and I came up with the same
solution you did.

So, yes, it does work. Thanks, and sorry for the confusion.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Sat, 23 Jan 2021 18:54:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Mon, 25 Jan 2021 17:16:01 GMT) Full text and rfc822 format available.

Message #56 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: reporter <laszlomail <at> protonmail.com>
Cc: "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Mon, 25 Jan 2021 19:14:52 +0200
tags 46033 fixed
close 46033 28.0.50
thanks

>> This is exactly what the patch does. Have you really tried it?
>
> Yes, I don't know what happened (I applied it manually), but I
> must have made an error, because it didn't work.
>
> Then I checked the original code and I came up with the same
> solution you did.
>
> So, yes, it does work. Thanks, and sorry for the confusion.

Thanks for confirming, now this is fixed.




Added tag(s) fixed. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 25 Jan 2021 17:16:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.0.50, send any further explanations to 46033 <at> debbugs.gnu.org and reporter <laszlomail <at> protonmail.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 25 Jan 2021 17:16:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46033; Package emacs. (Wed, 27 Jan 2021 18:11:02 GMT) Full text and rfc822 format available.

Message #63 received at 46033 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: reporter <laszlomail <at> protonmail.com>
Cc: "46033 <at> debbugs.gnu.org" <46033 <at> debbugs.gnu.org>
Subject: Re: bug#46033: up arrow in query replace should not step into the
 prompt
Date: Wed, 27 Jan 2021 20:10:14 +0200
[Message part 1 (text/plain, inline)]
>>> This is exactly what the patch does. Have you really tried it?
>>
>> Yes, I don't know what happened (I applied it manually), but I
>> must have made an error, because it didn't work.
>>
>> Then I checked the original code and I came up with the same
>> solution you did.
>>
>> So, yes, it does work. Thanks, and sorry for the confusion.
>
> Thanks for confirming, now this is fixed.

Actually, this is not so simple.  Currently this doesn't work with
multi-line minibuffer.  When there is non-prompt text on the previous line,
it should move point to the editable portion of that line.  So I pushed
this patch that supports not only multi-line minibuffer contents,
but also multi-line prompts.

[previous-line-or-history-element.patch (text/x-diff, inline)]
diff --git a/lisp/simple.el b/lisp/simple.el
index c878fdab92..680bfd7f43 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2472,14 +2472,24 @@ previous-line-or-history-element
 				   (save-excursion
 				     (goto-char (1- prompt-end))
 				     (current-column)))
-				0)
+				1)
 			 (current-column)))))
     (condition-case nil
 	(with-no-warnings
 	  (previous-line arg)
           ;; Avoid moving point to the prompt
           (when (< (point) (minibuffer-prompt-end))
-            (signal 'beginning-of-buffer nil)))
+            ;; If there is minibuffer contents on the same line
+            (if (<= (minibuffer-prompt-end)
+                    (save-excursion
+                      (if (or truncate-lines (not line-move-visual))
+                          (end-of-line)
+                        (end-of-visual-line))
+                      (point)))
+                ;; Move to the beginning of minibuffer contents
+                (goto-char (minibuffer-prompt-end))
+              ;; Otherwise, go to the previous history element
+              (signal 'beginning-of-buffer nil))))
       (beginning-of-buffer
        ;; Restore old position since `line-move-visual' moves point to
        ;; the beginning of the line when it fails to go to the previous line.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 25 Feb 2021 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 117 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.