unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 54173@debbugs.gnu.org
Subject: bug#54173: 28.0.91; Training wheels for query-replace
Date: Sun, 27 Feb 2022 11:17:08 +0100	[thread overview]
Message-ID: <87wnhgtxzv.fsf@gmail.com> (raw)
In-Reply-To: <83sfs4oe56.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 27 Feb 2022 11:24:53 +0200")

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

  reply	other threads:[~2022-02-27 10:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wnhgtxzv.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=54173@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).