unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#34972: [PATCH] Use a different name for the help buffer in query-replace
@ 2019-03-24 12:40 Michał Krzywkowski
  2019-03-31 20:11 ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Michał Krzywkowski @ 2019-03-24 12:40 UTC (permalink / raw)
  To: 34972


[-- Attachment #1.1: Type: text/plain, Size: 1951 bytes --]


Hi,

I use this to always display the *Help* buffer in the selected window,
or to reuse existing window displaying the same buffer:

  (add-to-list 'display-buffer-alist
               '("^\\*Help\\*$" . ((display-buffer-reuse-window
                                    display-buffer-same-window))))

With this, whenever I forget the keybindings available during
query-replace and hit '?' to get help, the help buffer is displayed in
the main window which shows the replacements to be performed.  When I
try to bury the help buffer with 'q', it doesn't do what I intended - it
quits the query-replace session.  The same thing happens when I try to
switch to the main window with 'C-x o' and manually kill the buffer.

The only thing that works really, is to enter recursive edit, kill the
help buffer and exit-recursive-edit.

This happens because the help buffer generated by perform-replace is
named "*Help*" and my display-buffer rule matches it.  I work around
this by adding an additional rule to display-buffer-alist which checks
if the help buffer was created by perform-replace.  It's ugly:

  (defun my//display-buffer-help-for-query-replace-condition (bufname action)
    (and (string-match-p "\\*Help\\*" bufname)
         (catch 'res
           (mapbacktrace (lambda (_evald func _args _flags)
                           (when (eq func 'perform-replace)
                             (throw 'res t)))))))
  (add-to-list 'display-buffer-alist
               '(my//display-buffer-help-for-query-replace-condition
                 . (display-buffer-pop-up-window)))


There are a couple of ways to improve behavior of perform-replace:

- Use a different name for the query-replace help buffer (patch attached)
- Make 'C-l' or some other key bury the help buffer, if it was displayed
  in the main window
- Make '?' toggle visibility of the help buffer
- Allow switching windows in query-replace
- Display the help message in the minibuffer


[-- Attachment #1.2: Patch --]
[-- Type: text/x-diff, Size: 1009 bytes --]

From 4cbd2022deb50a35ca38040ab0337f707834b3f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Krzywkowski?= <k.michal@zoho.com>
Date: Fri, 22 Mar 2019 18:36:21 +0100
Subject: [PATCH] Use a different name for the help buffer in query-replace

* lisp/replace.el (perform-replace): Use "*Query replace help*" for the name
  of the help buffer.
---
 lisp/replace.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/replace.el b/lisp/replace.el
index 59ad1a375b..153f8f8287 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2635,7 +2635,7 @@ perform-replace
 		  (setq def (lookup-key map key))
 		  ;; Restore the match data while we process the command.
 		  (cond ((eq def 'help)
-			 (with-output-to-temp-buffer "*Help*"
+			 (with-output-to-temp-buffer "*Query replace help*"
 			   (princ
 			    (concat "Query replacing "
 				    (if backward "backward " "")
-- 
Michał Krzywkowski
PGP: A5A7 06C4 28EF 8F64 2868 13A1 7BDE C129 F0B8 09A1



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



--
Michał Krzywkowski
PGP: A5A7 06C4 28EF 8F64 2868 13A1 7BDE C129 F0B8 09A1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

end of thread, other threads:[~2019-04-11 20:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-24 12:40 bug#34972: [PATCH] Use a different name for the help buffer in query-replace Michał Krzywkowski
2019-03-31 20:11 ` Juri Linkov
2019-04-01  9:12   ` Michał Krzywkowski
2019-04-01 20:07     ` Juri Linkov
2019-04-10 13:07       ` Michał Krzywkowski
2019-04-10 20:49         ` Juri Linkov
2019-04-10 21:02           ` Drew Adams
2019-04-11 20:56             ` bug#34972: [PATCH] Inhibit displaying help buffer in main window in perform-replace 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).