unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54173: 28.0.91; Training wheels for query-replace
@ 2022-02-26 22:15 Augusto Stoffel
  2022-02-27  6:54 ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Augusto Stoffel @ 2022-02-26 22:15 UTC (permalink / raw)
  To: 54173

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

I've been using query-replace for years but still seem to have trouble
remembering some of the keys.  How about making the help message next to
the prompt “(? for help)” customizable, with an option to include an
extra summary line?

See patch attached (note that it also slightly changes the faces of the
prompt).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-perform-replace-prompt-help-customizable.patch --]
[-- Type: text/x-patch, Size: 3777 bytes --]

From 80710d38d9335101108661a9685c449be2d56fde Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Sat, 26 Feb 2022 23:08:26 +0100
Subject: [PATCH] Make 'perform-replace' prompt help customizable

* lisp/replace.el (perform-replace-prompt-help): New defcustom, help
string shown next to 'perform-replace' prompt.
(query-replace-map): Reorder entries so that 'substitute-command-keys'
does the right job.
(perform-replace): Use 'perform-replace-prompt-help.
---
 lisp/replace.el | 46 +++++++++++++++++++++++++++++-----------------
 1 file changed, 29 insertions(+), 17 deletions(-)

diff --git a/lisp/replace.el b/lisp/replace.el
index 06be597855..c9300a22e4 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -148,6 +148,18 @@ query-replace-lazy-highlight
   :group 'matching
   :version "22.1")
 
+(defcustom perform-replace-prompt-help "\\<query-replace-map>(\\[help] for help)"
+  "Help string to show next to the `perform-replace' prompt."
+  :type '(choice (const :tag "Just advertise help"
+                        "\\<query-replace-map>(\\[help] for help)")
+                 (const :tag "One-line summary"
+                        "\\<query-replace-map>(\\[help] for help)
+Replace \\[act] once, \\[act-and-exit] and exit, \\[automatic] all; \
+skip to \\[skip] next, \\[backup] previous; \
+\\[undo-all] undo all."))
+  :group 'matching
+  :version "29.1")
+
 (defface query-replace
   '((t (:inherit isearch)))
   "Face for highlighting query replacement matches."
@@ -2451,12 +2463,12 @@ query-replace-map
     (define-key map "\d" 'skip)
     (define-key map [delete] 'skip)
     (define-key map [backspace] 'skip)
-    (define-key map "y" 'act)
-    (define-key map "n" 'skip)
     (define-key map "Y" 'act)
+    (define-key map "y" 'act)
     (define-key map "N" 'skip)
-    (define-key map "e" 'edit-replacement)
+    (define-key map "n" 'skip)
     (define-key map "E" 'edit-replacement)
+    (define-key map "e" 'edit-replacement)
     (define-key map "," 'act-and-show)
     (define-key map "q" 'exit)
     (define-key map "\r" 'exit)
@@ -2840,20 +2852,20 @@ perform-replace
          (match-again t)
 
          (message
-          (if query-flag
-              (apply #'propertize
-                     (concat "Query replacing "
-                             (if backward "backward " "")
-                             (if delimited-flag
-                                 (or (and (symbolp delimited-flag)
-                                          (get delimited-flag
-                                               'isearch-message-prefix))
-                                     "word ") "")
-                             (if regexp-flag "regexp " "")
-                             "%s with %s: "
-                             (substitute-command-keys
-                              "(\\<query-replace-map>\\[help] for help) "))
-                     minibuffer-prompt-properties))))
+          (when query-flag
+            (concat
+             (apply #'propertize
+                    (concat "Query replacing "
+                            (if backward "backward " "")
+                            (if delimited-flag
+                                (or (and (symbolp delimited-flag)
+                                         (get delimited-flag
+                                              'isearch-message-prefix))
+                                    "word ") "")
+                            (if regexp-flag "regexp " "")
+                            "%s with %s: ")
+                    minibuffer-prompt-properties)
+             (substitute-command-keys perform-replace-prompt-help)))))
 
     ;; Unless a single contiguous chunk is selected, operate on multiple chunks.
     (when region-noncontiguous-p
-- 
2.35.1


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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-26 22:15 bug#54173: 28.0.91; Training wheels for query-replace Augusto Stoffel
@ 2022-02-27  6:54 ` Eli Zaretskii
  2022-02-27  7:55   ` Augusto Stoffel
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-27  6:54 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 54173

> From: Augusto Stoffel <arstoffel@gmail.com>
> Date: Sat, 26 Feb 2022 23:15:12 +0100
> 
> I've been using query-replace for years but still seem to have trouble
> remembering some of the keys.  How about making the help message next to
> the prompt “(? for help)” customizable, with an option to include an
> extra summary line?

I don't think it's a good idea to leave documentation and help to
users.  I'd rather we made the help text better, or maybe introduce a
key to display a more detailed help text.  Emacs should not have
sub-optimal help text.

Can you tell why you have trouble remembering some of the keys, and
how changing the help message could countermand that?

Thanks.





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27  6:54 ` Eli Zaretskii
@ 2022-02-27  7:55   ` Augusto Stoffel
  2022-02-27  8:23     ` Eli Zaretskii
  2022-03-10 19:20     ` Juri Linkov
  0 siblings, 2 replies; 17+ messages in thread
From: Augusto Stoffel @ 2022-02-27  7:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 54173

On Sun, 27 Feb 2022 at 08:54, Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Augusto Stoffel <arstoffel@gmail.com>
>> Date: Sat, 26 Feb 2022 23:15:12 +0100
>> 
>> I've been using query-replace for years but still seem to have trouble
>> remembering some of the keys.  How about making the help message next to
>> the prompt “(? for help)” customizable, with an option to include an
>> extra summary line?
>
> I don't think it's a good idea to leave documentation and help to
> users.  I'd rather we made the help text better, or maybe introduce a
> key to display a more detailed help text.  Emacs should not have
> sub-optimal help text.

I agree, and I suggested a defcustom here so the user can choose between
two predefined options, the default prompt:

```
Query replacing a with b: (‘?’ for help)
```

and a two-line prompt including a little summary:

```
Query replacing a with b: (‘?’ for help)
Replace ‘y’ once, ‘.’ and exit, ‘!’ all; skip to ‘n’ next, ‘^’ previous; ‘U’ undo all.
```

(The quotation marks are not actually used, they are just representing
the help-key-keybinding face.  I choose this particular message because
it's the best I can fit in 80 columns.)

> Can you tell why you have trouble remembering some of the keys, and
> how changing the help message could countermand that?

My issue is mainly with '.' and '^'.  I rarely need those operations, so
by the time I do I already forgot the keys.  With a summary help line
below the prompt, it's very hard to not be reminded.

PS: Should we define 'p' as a synonym for '^' in 'query-replace-map'?





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27  7:55   ` Augusto Stoffel
@ 2022-02-27  8:23     ` Eli Zaretskii
  2022-02-27  8:51       ` Augusto Stoffel
  2022-03-10 19:20     ` Juri Linkov
  1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-27  8:23 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 54173

> From: Augusto Stoffel <arstoffel@gmail.com>
> Cc: 54173@debbugs.gnu.org
> Date: Sun, 27 Feb 2022 08:55:51 +0100
> 
> On Sun, 27 Feb 2022 at 08:54, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> > I don't think it's a good idea to leave documentation and help to
> > users.  I'd rather we made the help text better, or maybe introduce a
> > key to display a more detailed help text.  Emacs should not have
> > sub-optimal help text.
> 
> I agree, and I suggested a defcustom here so the user can choose between
> two predefined options, the default prompt:
> 
> ```
> Query replacing a with b: (‘?’ for help)
> ```
> 
> and a two-line prompt including a little summary:
> 
> ```
> Query replacing a with b: (‘?’ for help)
> Replace ‘y’ once, ‘.’ and exit, ‘!’ all; skip to ‘n’ next, ‘^’ previous; ‘U’ undo all.

But since '?' produces a more detailed help, and that help text stays
on display thereafter, do we really need one more variant?  Maybe the
default message could be expanded instead (but not to such a long
text, which would resize the mini-window in many cases)?

> > Can you tell why you have trouble remembering some of the keys, and
> > how changing the help message could countermand that?
> 
> My issue is mainly with '.' and '^'.  I rarely need those operations, so
> by the time I do I already forgot the keys.  With a summary help line
> below the prompt, it's very hard to not be reminded.

Then how about adding '.' and '^' to the default help text?

> PS: Should we define 'p' as a synonym for '^' in 'query-replace-map'?

Probably.





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27  8:23     ` Eli Zaretskii
@ 2022-02-27  8:51       ` Augusto Stoffel
  2022-02-27  9:24         ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Augusto Stoffel @ 2022-02-27  8:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 54173

On Sun, 27 Feb 2022 at 10:23, Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Augusto Stoffel <arstoffel@gmail.com>
>> Cc: 54173@debbugs.gnu.org
>> Date: Sun, 27 Feb 2022 08:55:51 +0100
>> 
>> On Sun, 27 Feb 2022 at 08:54, Eli Zaretskii <eliz@gnu.org> wrote:
>> 
>> > I don't think it's a good idea to leave documentation and help to
>> > users.  I'd rather we made the help text better, or maybe introduce a
>> > key to display a more detailed help text.  Emacs should not have
>> > sub-optimal help text.
>> 
>> I agree, and I suggested a defcustom here so the user can choose between
>> two predefined options, the default prompt:
>> 
>> ```
>> Query replacing a with b: (‘?’ for help)
>> ```
>> 
>> and a two-line prompt including a little summary:
>> 
>> ```
>> Query replacing a with b: (‘?’ for help)
>> Replace ‘y’ once, ‘.’ and exit, ‘!’ all; skip to ‘n’ next, ‘^’ previous; ‘U’ undo all.
>
> But since '?' produces a more detailed help, and that help text stays
> on display thereafter, do we really need one more variant?  Maybe the
> default message could be expanded instead (but not to such a long
> text, which would resize the mini-window in many cases)?

I think ‘y’ and ‘n’ are intuitive enough that they don't need a
reminder.  But mentioning the more uncommon ones (‘.’ and so on) without
talking about ‘y’ and ‘n’ is weird.

So I can't see any meaningful options between the status quo and my
suggestion above.

The way I use Emacs, this would be a perfectly fine message with no risk
of resizing the mini-window:

```
Query replacing a with b: (replace ‘y’ once, ‘.’ and exit, ‘!’ all; skip to ‘n’ next, ‘^’ previous; ‘U’ undo all; ‘?’ help)
```

One idea would be to choose between the short and long messages based on
the size of the miniwindow as well as the length regexp and replacement
text.

>> > Can you tell why you have trouble remembering some of the keys, and
>> > how changing the help message could countermand that?
>> 
>> My issue is mainly with '.' and '^'.  I rarely need those operations, so
>> by the time I do I already forgot the keys.  With a summary help line
>> below the prompt, it's very hard to not be reminded.
>
> Then how about adding '.' and '^' to the default help text?
>
>> PS: Should we define 'p' as a synonym for '^' in 'query-replace-map'?
>
> Probably.





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27  8:51       ` Augusto Stoffel
@ 2022-02-27  9:24         ` Eli Zaretskii
  2022-02-27 10:17           ` Augusto Stoffel
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-27  9:24 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 54173

> From: Augusto Stoffel <arstoffel@gmail.com>
> Cc: 54173@debbugs.gnu.org
> Date: Sun, 27 Feb 2022 09:51:42 +0100
> 
> > But since '?' produces a more detailed help, and that help text stays
> > on display thereafter, do we really need one more variant?  Maybe the
> > default message could be expanded instead (but not to such a long
> > text, which would resize the mini-window in many cases)?
> 
> I think ‘y’ and ‘n’ are intuitive enough that they don't need a
> reminder.  But mentioning the more uncommon ones (‘.’ and so on) without
> talking about ‘y’ and ‘n’ is weird.

How about the below?

  (‘y’/‘n’, ‘.’ replace & exit, ‘^’ back up, ‘?’ help)

An alternative is to have C-h and F1 temporarily show a longer line
with more commands.

> One idea would be to choose between the short and long messages based on
> the size of the miniwindow as well as the length regexp and replacement
> text.

That could also be a possibility.





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27  9:24         ` Eli Zaretskii
@ 2022-02-27 10:17           ` Augusto Stoffel
  2022-02-27 10:55             ` Eli Zaretskii
  2022-02-27 13:10             ` Lars Ingebrigtsen
  0 siblings, 2 replies; 17+ messages in thread
From: Augusto Stoffel @ 2022-02-27 10:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 54173

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

On Sun, 27 Feb 2022 at 11:24, Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Augusto Stoffel <arstoffel@gmail.com>
>> Cc: 54173@debbugs.gnu.org
>> Date: Sun, 27 Feb 2022 09:51:42 +0100
>> 
>> > But since '?' produces a more detailed help, and that help text stays
>> > on display thereafter, do we really need one more variant?  Maybe the
>> > default message could be expanded instead (but not to such a long
>> > text, which would resize the mini-window in many cases)?
>> 
>> I think ‘y’ and ‘n’ are intuitive enough that they don't need a
>> reminder.  But mentioning the more uncommon ones (‘.’ and so on) without
>> talking about ‘y’ and ‘n’ is weird.
>
> How about the below?
>
>   (‘y’/‘n’, ‘.’ replace & exit, ‘^’ back up, ‘?’ help)

I find this better than the status quo.  I've attached the patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Expand-help-string-in-perform-replace-prompt.patch --]
[-- Type: text/x-patch, Size: 3372 bytes --]

From 290ad346d793d42c654adbde87089b22f4aa0fa5 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Sat, 26 Feb 2022 23:08:26 +0100
Subject: [PATCH] Expand help string in 'perform-replace' prompt

* lisp/replace.el (query-replace-prompt-help): New variable, help
string shown next to 'perform-replace' prompt.
(query-replace-map): Reorder entries so that 'substitute-command-keys'
does the right job.
(perform-replace): Use 'query-replace-prompt-help.
---
 lisp/replace.el | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/lisp/replace.el b/lisp/replace.el
index 06be597855..49cf652ddc 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2445,18 +2445,22 @@ query-replace-help
 in the current buffer."
   "Help message while in `query-replace'.")
 
+(defvar query-replace-prompt-help
+  "\\<query-replace-map>(\\[act]/\\[skip], \\[act-and-exit] replace & exit, \\[backup] back up, \\[help] help)"
+  "Help string to show next to the `query-replace' prompt.")
+
 (defvar query-replace-map
   (let ((map (make-sparse-keymap)))
     (define-key map " " 'act)
     (define-key map "\d" 'skip)
     (define-key map [delete] 'skip)
     (define-key map [backspace] 'skip)
-    (define-key map "y" 'act)
-    (define-key map "n" 'skip)
     (define-key map "Y" 'act)
+    (define-key map "y" 'act)
     (define-key map "N" 'skip)
-    (define-key map "e" 'edit-replacement)
+    (define-key map "n" 'skip)
     (define-key map "E" 'edit-replacement)
+    (define-key map "e" 'edit-replacement)
     (define-key map "," 'act-and-show)
     (define-key map "q" 'exit)
     (define-key map "\r" 'exit)
@@ -2840,20 +2844,20 @@ perform-replace
          (match-again t)
 
          (message
-          (if query-flag
-              (apply #'propertize
-                     (concat "Query replacing "
-                             (if backward "backward " "")
-                             (if delimited-flag
-                                 (or (and (symbolp delimited-flag)
-                                          (get delimited-flag
-                                               'isearch-message-prefix))
-                                     "word ") "")
-                             (if regexp-flag "regexp " "")
-                             "%s with %s: "
-                             (substitute-command-keys
-                              "(\\<query-replace-map>\\[help] for help) "))
-                     minibuffer-prompt-properties))))
+          (when query-flag
+            (concat
+             (apply #'propertize
+                    (concat "Query replacing "
+                            (if backward "backward " "")
+                            (if delimited-flag
+                                (or (and (symbolp delimited-flag)
+                                         (get delimited-flag
+                                              'isearch-message-prefix))
+                                    "word ") "")
+                            (if regexp-flag "regexp " "")
+                            "%s with %s: ")
+                    minibuffer-prompt-properties)
+             (substitute-command-keys query-replace-prompt-help)))))
 
     ;; Unless a single contiguous chunk is selected, operate on multiple chunks.
     (when region-noncontiguous-p
-- 
2.35.1


[-- Attachment #3: Type: text/plain, Size: 408 bytes --]



> An alternative is to have C-h and F1 temporarily show a longer line
> with more commands.
>
>> One idea would be to choose between the short and long messages based on
>> the size of the miniwindow as well as the length regexp and replacement
>> text.
>
> That could also be a possibility.

Between this and your suggestion, I'm undecided what's better.  Perhaps
this is more complicated than necessary.

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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27 10:17           ` Augusto Stoffel
@ 2022-02-27 10:55             ` Eli Zaretskii
  2022-02-27 16:11               ` bug#54173: [External] : " Drew Adams
  2022-02-27 13:10             ` Lars Ingebrigtsen
  1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-27 10:55 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 54173

> From: Augusto Stoffel <arstoffel@gmail.com>
> Cc: 54173@debbugs.gnu.org
> Date: Sun, 27 Feb 2022 11:17:08 +0100
> 
> >> I think ‘y’ and ‘n’ are intuitive enough that they don't need a
> >> reminder.  But mentioning the more uncommon ones (‘.’ and so on) without
> >> talking about ‘y’ and ‘n’ is weird.
> >
> > How about the below?
> >
> >   (‘y’/‘n’, ‘.’ replace & exit, ‘^’ back up, ‘?’ help)
> 
> I find this better than the status quo.  I've attached the patch.

Thanks.  Let's wait a bit to let others chime in and express their
opinions.

> >> One idea would be to choose between the short and long messages based on
> >> the size of the miniwindow as well as the length regexp and replacement
> >> text.
> >
> > That could also be a possibility.
> 
> Between this and your suggestion, I'm undecided what's better.  Perhaps
> this is more complicated than necessary.

Let's see what others think.





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27 10:17           ` Augusto Stoffel
  2022-02-27 10:55             ` Eli Zaretskii
@ 2022-02-27 13:10             ` Lars Ingebrigtsen
  2022-02-27 13:46               ` Augusto Stoffel
  1 sibling, 1 reply; 17+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-27 13:10 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 54173

Augusto Stoffel <arstoffel@gmail.com> writes:

> -    (define-key map "y" 'act)
> -    (define-key map "n" 'skip)
>      (define-key map "Y" 'act)
> +    (define-key map "y" 'act)
>      (define-key map "N" 'skip)
> -    (define-key map "e" 'edit-replacement)
> +    (define-key map "n" 'skip)
>      (define-key map "E" 'edit-replacement)
> +    (define-key map "e" 'edit-replacement)

This seems unrelated, and just moves bindings around?

>> >   (‘y’/‘n’, ‘.’ replace & exit, ‘^’ back up, ‘?’ help)
>> 
>> I find this better than the status quo.  I've attached the patch.
>
> Thanks.  Let's wait a bit to let others chime in and express their
> opinions.

I'm not sure I understood the patch.  Is the proposal to append all that
to "Query replacing foo with bar"?  It'll make prompts commonly be
longer than a line, and it's pretty noisy, so if that's the proposal,
I'm against it.

The help is on `?', so I don't see the point, either.

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





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27 13:10             ` Lars Ingebrigtsen
@ 2022-02-27 13:46               ` Augusto Stoffel
  2022-03-03 16:41                 ` Augusto Stoffel
  0 siblings, 1 reply; 17+ messages in thread
From: Augusto Stoffel @ 2022-02-27 13:46 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 54173

On Sun, 27 Feb 2022 at 14:10, Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Augusto Stoffel <arstoffel@gmail.com> writes:
>
>> -    (define-key map "y" 'act)
>> -    (define-key map "n" 'skip)
>>      (define-key map "Y" 'act)
>> +    (define-key map "y" 'act)
>>      (define-key map "N" 'skip)
>> -    (define-key map "e" 'edit-replacement)
>> +    (define-key map "n" 'skip)
>>      (define-key map "E" 'edit-replacement)
>> +    (define-key map "e" 'edit-replacement)
>
> This seems unrelated, and just moves bindings around?

This is so that 'substitute-command-keys' pick up the right key for each
command, that is, the lower cased ones.

>>> >   (‘y’/‘n’, ‘.’ replace & exit, ‘^’ back up, ‘?’ help)
>>> 
>>> I find this better than the status quo.  I've attached the patch.
>>
>> Thanks.  Let's wait a bit to let others chime in and express their
>> opinions.
>
> I'm not sure I understood the patch.  Is the proposal to append all that
> to "Query replacing foo with bar"?  It'll make prompts commonly be
> longer than a line, and it's pretty noisy, so if that's the proposal,
> I'm against it.

Well, yes, that's the proposal...

At least now that string is a defvar that you can set to nil if you want
to save some columns :-)

> The help is on `?', so I don't see the point, either.

I think it's just nice to have a constant reminder of ‘.’ and ‘^’.  Of
course I'll remember them after all this discussion, but until now I
could never quite recall them when the occasion arose.





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

* bug#54173: [External] : bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27 10:55             ` Eli Zaretskii
@ 2022-02-27 16:11               ` Drew Adams
  0 siblings, 0 replies; 17+ messages in thread
From: Drew Adams @ 2022-02-27 16:11 UTC (permalink / raw)
  To: Eli Zaretskii, Augusto Stoffel; +Cc: 54173@debbugs.gnu.org

> > > How about the below?
> > >
> > >   (‘y’/‘n’, ‘.’ replace & exit, ‘^’ back up, ‘?’ help)
> >
> > I find this better than the status quo.  I've attached the patch.
> 
> Thanks.  Let's wait a bit to let others chime in and express their
> opinions.

Just a quick nit about the proposed prompt text.  (Not
commenting on the rest of your exchange; you seem to
be discussing it fruitfully.)

My comment on that text: The clauses separated by
commas each show a key followed by a brief description
of what the key does.  _Except_ for "`y'/`n'".  It's
not necessarily obvious what the y/n behaviors are.

And even if you think the y/n behaviors are obvious,
it's not so easy to parse the message, splitting it
properly at commas - especially given the inconsistent
treatment of y/n.

1. Consider adding at least some text after `y'/`n'
(maybe "replace this" or just "this" or just "here"?).

2. I wonder if it also might be clearer to drop the
quotes, add a colon, and perhaps to use a semicolon
or slash as separator:

(y/n: replace here / .: replace & exit / ^: back up / ?: help)

versus

(‘y’/‘n’ <what?>, ‘.’ replace & exit, ‘^’ back up, ‘?’ help)

Just a suggestion, to consider both y/n action and
better separation.  You may well find other/better
ways to address those two questions.

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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27 13:46               ` Augusto Stoffel
@ 2022-03-03 16:41                 ` Augusto Stoffel
  2022-03-10 19:24                   ` Juri Linkov
  0 siblings, 1 reply; 17+ messages in thread
From: Augusto Stoffel @ 2022-03-03 16:41 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 54173, Lars Ingebrigtsen

>> I'm not sure I understood the patch.  Is the proposal to append all that
>> to "Query replacing foo with bar"?  It'll make prompts commonly be
>> longer than a line, and it's pretty noisy, so if that's the proposal,
>> I'm against it.
>
> Well, yes, that's the proposal...
>
> At least now that string is a defvar that you can set to nil if you want
> to save some columns :-)

I'm including Juri in this thread so maybe we can get one more opinion.

Let me also say that we could modify the patch so that the help message
remains the same, i.e., just “(? for help)”.  Then at least it's not
hardcoded anymore.





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-02-27  7:55   ` Augusto Stoffel
  2022-02-27  8:23     ` Eli Zaretskii
@ 2022-03-10 19:20     ` Juri Linkov
  1 sibling, 0 replies; 17+ messages in thread
From: Juri Linkov @ 2022-03-10 19:20 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 54173

> PS: Should we define 'p' as a synonym for '^' in 'query-replace-map'?

In my config I rebound '^' to 'C-r' to be like in isearch-mode,
so 'C-r' goes backward, 'C-s' forward, and 'M-e' is like
'isearch-edit-string':

  (define-key query-replace-map "\C-s" 'skip)
  (define-key query-replace-map "\C-r" 'backup)
  (define-key query-replace-map "\M-e" 'edit-replacement)
  (define-key query-replace-map "\M-\C-r" 'edit)





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-03-03 16:41                 ` Augusto Stoffel
@ 2022-03-10 19:24                   ` Juri Linkov
  2022-03-10 19:28                     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2022-03-10 19:24 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 54173, Lars Ingebrigtsen

>>> I'm not sure I understood the patch.  Is the proposal to append all that
>>> to "Query replacing foo with bar"?  It'll make prompts commonly be
>>> longer than a line, and it's pretty noisy, so if that's the proposal,
>>> I'm against it.
>>
>> Well, yes, that's the proposal...
>>
>> At least now that string is a defvar that you can set to nil if you want
>> to save some columns :-)
>
> I'm including Juri in this thread so maybe we can get one more opinion.
>
> Let me also say that we could modify the patch so that the help message
> remains the same, i.e., just “(? for help)”.  Then at least it's not
> hardcoded anymore.

Please don't change the default succinct prompt.

If you think someone might want to display reminders for some rarely used
keys, then a variable with a help string would be fine.





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-03-10 19:24                   ` Juri Linkov
@ 2022-03-10 19:28                     ` Lars Ingebrigtsen
  2022-03-10 19:44                       ` Juri Linkov
  0 siblings, 1 reply; 17+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-10 19:28 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 54173, Augusto Stoffel

Juri Linkov <juri@linkov.net> writes:

> If you think someone might want to display reminders for some rarely used
> keys, then a variable with a help string would be fine.

I think the likelihood of a user customising such a string is pretty
much nil -- if they're able to formulate a longer help string here, then
they'll remember the options they typed out.

So I don't think a variable here would be generally useful.  If the
original submitter wants to change the string for themselves, they can
advise the function for themselves, or use `set-message-function' to
alter the prompt.

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





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-03-10 19:28                     ` Lars Ingebrigtsen
@ 2022-03-10 19:44                       ` Juri Linkov
  2022-03-12 16:58                         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2022-03-10 19:44 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 54173, Augusto Stoffel

>> If you think someone might want to display reminders for some rarely used
>> keys, then a variable with a help string would be fine.
>
> I think the likelihood of a user customising such a string is pretty
> much nil -- if they're able to formulate a longer help string here, then
> they'll remember the options they typed out.

I agree that probability tends to zero.

OTOH, there is already such a const:

  (defconst query-replace-help "...")

that is used in:

  (substitute-command-keys query-replace-help)

So the same way a new const makes sense:

  (defconst query-replace-prompt-help "(\\<query-replace-map>\\[help] for help) ")

to be used like this:

  (substitute-command-keys query-replace-prompt-help)

that will help Augusto to solve this problem.





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

* bug#54173: 28.0.91; Training wheels for query-replace
  2022-03-10 19:44                       ` Juri Linkov
@ 2022-03-12 16:58                         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 17+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-12 16:58 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 54173, Augusto Stoffel

Juri Linkov <juri@linkov.net> writes:

>> I think the likelihood of a user customising such a string is pretty
>> much nil -- if they're able to formulate a longer help string here, then
>> they'll remember the options they typed out.
>
> I agree that probability tends to zero.
>
> OTOH, there is already such a const:
>
>   (defconst query-replace-help "...")
>
> that is used in:
>
>   (substitute-command-keys query-replace-help)
>
> So the same way a new const makes sense:
>
>   (defconst query-replace-prompt-help "(\\<query-replace-map>\\[help]
> for help) ")
>
> to be used like this:
>
>   (substitute-command-keys query-replace-prompt-help)
>
> that will help Augusto to solve this problem.

I suspect that the former is just a const because people don't like to
put walls of texts inside function definitions because it makes it more
difficult to read the code, not because they thought anybody would want
to change it.

And that's not really the case with the prompt.

So I'm leaning towards us not wanting to change anything here, and I'm
therefore closing this bug report.

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





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

end of thread, other threads:[~2022-03-12 16:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-26 22:15 bug#54173: 28.0.91; Training wheels for query-replace Augusto Stoffel
2022-02-27  6:54 ` Eli Zaretskii
2022-02-27  7:55   ` Augusto Stoffel
2022-02-27  8:23     ` Eli Zaretskii
2022-02-27  8:51       ` Augusto Stoffel
2022-02-27  9:24         ` Eli Zaretskii
2022-02-27 10:17           ` Augusto Stoffel
2022-02-27 10:55             ` Eli Zaretskii
2022-02-27 16:11               ` bug#54173: [External] : " Drew Adams
2022-02-27 13:10             ` Lars Ingebrigtsen
2022-02-27 13:46               ` Augusto Stoffel
2022-03-03 16:41                 ` Augusto Stoffel
2022-03-10 19:24                   ` Juri Linkov
2022-03-10 19:28                     ` Lars Ingebrigtsen
2022-03-10 19:44                       ` Juri Linkov
2022-03-12 16:58                         ` Lars Ingebrigtsen
2022-03-10 19:20     ` Juri Linkov

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