all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: 54173@debbugs.gnu.org
Subject: bug#54173: 28.0.91; Training wheels for query-replace
Date: Sat, 26 Feb 2022 23:15:12 +0100	[thread overview]
Message-ID: <87a6edi8b3.fsf@gmail.com> (raw)

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


             reply	other threads:[~2022-02-26 22:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-26 22:15 Augusto Stoffel [this message]
2022-02-27  6:54 ` bug#54173: 28.0.91; Training wheels for query-replace 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

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

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

  git send-email \
    --in-reply-to=87a6edi8b3.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=54173@debbugs.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.