unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46033: up arrow in query replace should not step into the prompt
@ 2021-01-22 13:21 laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-01-22 13:55 ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-01-22 13:21 UTC (permalink / raw)
  To: 46033

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.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-22 13:21 bug#46033: up arrow in query replace should not step into the prompt laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-01-22 13:55 ` Eli Zaretskii
  2021-01-22 14:16   ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-01-22 18:44   ` Lars Ingebrigtsen
  0 siblings, 2 replies; 15+ messages in thread
From: Eli Zaretskii @ 2021-01-22 13:55 UTC (permalink / raw)
  To: reporter; +Cc: 46033

> 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@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.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-22 13:55 ` Eli Zaretskii
@ 2021-01-22 14:16   ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-01-23 17:24     ` Juri Linkov
  2021-01-22 18:44   ` Lars Ingebrigtsen
  1 sibling, 1 reply; 15+ messages in thread
From: laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-01-22 14:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 46033@debbugs.gnu.org

>
> 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.







^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-22 13:55 ` Eli Zaretskii
  2021-01-22 14:16   ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-01-22 18:44   ` Lars Ingebrigtsen
  2021-01-22 18:52     ` Eli Zaretskii
  1 sibling, 1 reply; 15+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-22 18:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: reporter, 46033

Eli Zaretskii <eliz@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





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-22 18:44   ` Lars Ingebrigtsen
@ 2021-01-22 18:52     ` Eli Zaretskii
  2021-01-23 17:35       ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2021-01-22 18:52 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: laszlomail, 46033

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: reporter <laszlomail@protonmail.com>,  46033@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.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-22 14:16   ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-01-23 17:24     ` Juri Linkov
  2021-01-23 17:46       ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 15+ messages in thread
From: Juri Linkov @ 2021-01-23 17:24 UTC (permalink / raw)
  To: 46033; +Cc: laszlomail

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]

>> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: avoid-minibuffer-prompt.patch --]
[-- Type: text/x-diff, Size: 627 bytes --]

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.

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-22 18:52     ` Eli Zaretskii
@ 2021-01-23 17:35       ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-01-23 18:17         ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 15+ messages in thread
From: laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-01-23 17:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, 46033@debbugs.gnu.org

>
> 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






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-23 17:24     ` Juri Linkov
@ 2021-01-23 17:46       ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-01-23 18:34         ` Juri Linkov
  0 siblings, 1 reply; 15+ messages in thread
From: laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-01-23 17:46 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 46033

[-- Attachment #1: Type: text/plain, Size: 598 bytes --]

>
> 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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: avoid-minibuffer-prompt.patch --]
[-- Type: text/x-diff; name=avoid-minibuffer-prompt.patch, Size: 627 bytes --]

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.

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-23 17:35       ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-01-23 18:17         ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-01-23 18:30           ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 15+ messages in thread
From: laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-01-23 18:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, 46033@debbugs.gnu.org

[-- Attachment #1: Type: text/plain, Size: 195 bytes --]

>
> 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.

[-- Attachment #2: prompt.patch --]
[-- Type: application/octet-stream, Size: 777 bytes --]

c:/Progra~2/GnuWin32/bin/diff.exe -u "c:/Program Files/emacs-27.1/share/emacs/27.1/lisp/simple.el" "d:/download/simple.el"
--- c:/Program Files/emacs-27.1/share/emacs/27.1/lisp/simple.el	2020-08-12 08:36:54.000000000 +0200
+++ d:/download/simple.el	2021-01-23 19:15:00.428631300 +0100
@@ -2303,6 +2303,9 @@
 			 (current-column)))))
     (condition-case nil
 	(with-no-warnings
+          (if (eq (point-min) ;; prompt is entirely visible
+                  (- (minibuffer-prompt-end) (length (minibuffer-prompt))))
+              (signal 'beginning-of-buffer nil)) ;; get previous history item
 	  (previous-line arg))
       (beginning-of-buffer
        ;; Restore old position since `line-move-visual' moves point to

Diff finished.  Sat Jan 23 19:15:02 2021

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-23 18:17         ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-01-23 18:30           ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-01-23 18:33             ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 15+ messages in thread
From: laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-01-23 18:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, 46033@debbugs.gnu.org

[-- Attachment #1: Type: text/plain, Size: 85 bytes --]

>
> Attached a patch doing what I propose.


Fixed typo (using window-start).


[-- Attachment #2: prompt.patch --]
[-- Type: application/octet-stream, Size: 780 bytes --]

c:/Progra~2/GnuWin32/bin/diff.exe -u "c:/Program Files/emacs-27.1/share/emacs/27.1/lisp/simple.el" "d:/download/simple.el"
--- c:/Program Files/emacs-27.1/share/emacs/27.1/lisp/simple.el	2020-08-12 08:36:54.000000000 +0200
+++ d:/download/simple.el	2021-01-23 19:28:19.752834800 +0100
@@ -2303,6 +2303,9 @@
 			 (current-column)))))
     (condition-case nil
 	(with-no-warnings
+          (if (eq (window-start) ;; prompt is entirely visible
+                  (- (minibuffer-prompt-end) (length (minibuffer-prompt))))
+              (signal 'beginning-of-buffer nil)) ;; get previous history item
 	  (previous-line arg))
       (beginning-of-buffer
        ;; Restore old position since `line-move-visual' moves point to

Diff finished.  Sat Jan 23 19:28:42 2021

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-23 18:30           ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-01-23 18:33             ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 15+ messages in thread
From: laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-01-23 18:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, 46033@debbugs.gnu.org

[-- Attachment #1: Type: text/plain, Size: 110 bytes --]

> > Attached a patch doing what I propose.
>
> Fixed typo (using window-start).


Third time's a charm.

[-- Attachment #2: prompt.patch --]
[-- Type: application/octet-stream, Size: 716 bytes --]

c:/Progra~2/GnuWin32/bin/diff.exe -u "c:/Program Files/emacs-27.1/share/emacs/27.1/lisp/simple.el" "d:/download/simple.el"
--- c:/Program Files/emacs-27.1/share/emacs/27.1/lisp/simple.el	2020-08-12 08:36:54.000000000 +0200
+++ d:/download/simple.el	2021-01-23 19:31:50.824461200 +0100
@@ -2303,6 +2303,8 @@
 			 (current-column)))))
     (condition-case nil
 	(with-no-warnings
+          (if (eq (window-start) (point-min))  ;; prompt is entirely visible
+              (signal 'beginning-of-buffer nil)) ;; get previous history item
 	  (previous-line arg))
       (beginning-of-buffer
        ;; Restore old position since `line-move-visual' moves point to

Diff finished.  Sat Jan 23 19:32:06 2021

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-23 17:46       ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-01-23 18:34         ` Juri Linkov
  2021-01-23 18:53           ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 15+ messages in thread
From: Juri Linkov @ 2021-01-23 18:34 UTC (permalink / raw)
  To: reporter; +Cc: 46033

>> 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?





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-23 18:34         ` Juri Linkov
@ 2021-01-23 18:53           ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-01-25 17:14             ` Juri Linkov
  0 siblings, 1 reply; 15+ messages in thread
From: laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-01-23 18:53 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 46033

>
> 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.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-23 18:53           ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-01-25 17:14             ` Juri Linkov
  2021-01-27 18:10               ` Juri Linkov
  0 siblings, 1 reply; 15+ messages in thread
From: Juri Linkov @ 2021-01-25 17:14 UTC (permalink / raw)
  To: reporter; +Cc: 46033@debbugs.gnu.org

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.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#46033: up arrow in query replace should not step into the prompt
  2021-01-25 17:14             ` Juri Linkov
@ 2021-01-27 18:10               ` Juri Linkov
  0 siblings, 0 replies; 15+ messages in thread
From: Juri Linkov @ 2021-01-27 18:10 UTC (permalink / raw)
  To: reporter; +Cc: 46033@debbugs.gnu.org

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

>>> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: previous-line-or-history-element.patch --]
[-- Type: text/x-diff, Size: 1282 bytes --]

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.

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-01-27 18:10 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 13:21 bug#46033: up arrow in query replace should not step into the prompt laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-01-22 13:55 ` Eli Zaretskii
2021-01-22 14:16   ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-01-23 17:24     ` Juri Linkov
2021-01-23 17:46       ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-01-23 18:34         ` Juri Linkov
2021-01-23 18:53           ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-01-25 17:14             ` Juri Linkov
2021-01-27 18:10               ` Juri Linkov
2021-01-22 18:44   ` Lars Ingebrigtsen
2021-01-22 18:52     ` Eli Zaretskii
2021-01-23 17:35       ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-01-23 18:17         ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-01-23 18:30           ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-01-23 18:33             ` laszlomail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors

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).