GNU bug report logs - #34972
[PATCH] Inhibit displaying help buffer in main window in perform-replace

Previous Next

Package: emacs;

Reported by: Michał Krzywkowski <mkrzywkow <at> gmail.com>

Date: Sun, 24 Mar 2019 12:42:01 UTC

Severity: normal

Tags: patch

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 34972 in the body.
You can then email your comments to 34972 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#34972; Package emacs. (Sun, 24 Mar 2019 12:42:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michał Krzywkowski <mkrzywkow <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 24 Mar 2019 12:42:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michał Krzywkowski <mkrzywkow <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Use a different name for the help buffer in query-replace
Date: Sun, 24 Mar 2019 13:40:11 +0100
[Message part 1 (text/plain, inline)]
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

[0001-Use-a-different-name-for-the-help-buffer-in-query-re.patch (text/x-diff, attachment)]
[Message part 3 (text/plain, inline)]

--
Michał Krzywkowski
PGP: A5A7 06C4 28EF 8F64 2868 13A1 7BDE C129 F0B8 09A1
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34972; Package emacs. (Sun, 31 Mar 2019 20:17:02 GMT) Full text and rfc822 format available.

Message #8 received at 34972 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Michał Krzywkowski <mkrzywkow <at> gmail.com>
Cc: 34972 <at> debbugs.gnu.org
Subject: Re: bug#34972: [PATCH] Use a different name for the help buffer in
 query-replace
Date: Sun, 31 Mar 2019 23:11:48 +0300
> 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

To solve the same problem, isearch binds display-buffer-overriding-action
to isearch--display-help-action with '(nil (inhibit-same-window . t))
that forces the *Help* buffer to be displayed in another window.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34972; Package emacs. (Mon, 01 Apr 2019 09:13:02 GMT) Full text and rfc822 format available.

Message #11 received at 34972 <at> debbugs.gnu.org (full text, mbox):

From: Michał Krzywkowski <mkrzywkow <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Michał Krzywkowski <mkrzywkow <at> gmail.com>,
 34972 <at> debbugs.gnu.org
Subject: Re: bug#34972: [PATCH] Use a different name for the help buffer in
 query-replace
Date: Mon, 01 Apr 2019 11:12:20 +0200
[Message part 1 (text/plain, inline)]
Hi Juri,

>> 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
>
> To solve the same problem, isearch binds display-buffer-overriding-action
> to isearch--display-help-action with '(nil (inhibit-same-window . t))
> that forces the *Help* buffer to be displayed in another window.

Thanks for letting me know.  I'm attaching a different patch which uses
display-buffer-overriding-action.  Does it look OK?

[0001-Inhibit-displaying-help-buffer-in-main-window-in-per.patch (text/x-diff, inline)]
From c3a1806b355228b28b70ddce716b6f578e9eacb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Krzywkowski?= <k.michal <at> zoho.com>
Date: Mon, 1 Apr 2019 10:26:46 +0200
Subject: [PATCH] Inhibit displaying help buffer in main window in
 perform-replace

* lisp/replace.el (perform-replace): Use
  display-buffer-overriding-action with inhibit-same-window to prevent
  the help buffer from being displayed in the main window.  (Bug#34972)
---
 lisp/replace.el | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/lisp/replace.el b/lisp/replace.el
index 318a9fb025..bd96fc3300 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2643,22 +2643,24 @@ 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*"
-			   (princ
-			    (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 " "")
-				    from-string " with "
-				    next-replacement ".\n\n"
-				    (substitute-command-keys
-				     query-replace-help)))
-			   (with-current-buffer standard-output
-			     (help-mode))))
+                         (let ((display-buffer-overriding-action
+                                '(nil (inhibit-same-window . t))))
+			   (with-output-to-temp-buffer "*Help*"
+			     (princ
+			      (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 " "")
+				      from-string " with "
+				      next-replacement ".\n\n"
+				      (substitute-command-keys
+				       query-replace-help)))
+			     (with-current-buffer standard-output
+			       (help-mode)))))
 			((eq def 'exit)
 			 (setq keep-going nil)
 			 (setq done t))
-- 
Michał Krzywkowski
PGP: A5A7 06C4 28EF 8F64 2868 13A1 7BDE C129 F0B8 09A1


[Message part 3 (text/plain, inline)]
--
Michał Krzywkowski
PGP: A5A7 06C4 28EF 8F64 2868 13A1 7BDE C129 F0B8 09A1
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34972; Package emacs. (Mon, 01 Apr 2019 20:47:04 GMT) Full text and rfc822 format available.

Message #14 received at 34972 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Michał Krzywkowski <mkrzywkow <at> gmail.com>
Cc: 34972 <at> debbugs.gnu.org
Subject: Re: bug#34972: [PATCH] Use a different name for the help buffer in
 query-replace
Date: Mon, 01 Apr 2019 23:07:15 +0300
> Thanks for letting me know.  I'm attaching a different patch which uses
> display-buffer-overriding-action.  Does it look OK?

I tried your patch, and see that it solves the problem.
My customization binds "*Help*" to display-buffer-same-window too,
so I had the same problem, and my old solution was to refrain
from using help in query-replace :)  Thanks for finally fixing this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34972; Package emacs. (Wed, 10 Apr 2019 13:08:02 GMT) Full text and rfc822 format available.

Message #17 received at 34972 <at> debbugs.gnu.org (full text, mbox):

From: Michał Krzywkowski <mkrzywkow <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Michał Krzywkowski <mkrzywkow <at> gmail.com>,
 34972 <at> debbugs.gnu.org
Subject: Re: bug#34972: [PATCH] Use a different name for the help buffer in
 query-replace
Date: Wed, 10 Apr 2019 15:07:23 +0200
[Message part 1 (text/plain, inline)]
Thanks for testing, Juri.

Since the patch fixes the bug, will it be applied any time soon?

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

[signature.asc (application/pgp-signature, inline)]

Reply sent to Juri Linkov <juri <at> linkov.net>:
You have taken responsibility. (Wed, 10 Apr 2019 20:52:03 GMT) Full text and rfc822 format available.

Notification sent to Michał Krzywkowski <mkrzywkow <at> gmail.com>:
bug acknowledged by developer. (Wed, 10 Apr 2019 20:52:03 GMT) Full text and rfc822 format available.

Message #22 received at 34972-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Michał Krzywkowski <mkrzywkow <at> gmail.com>
Cc: 34972-done <at> debbugs.gnu.org
Subject: Re: bug#34972: [PATCH] Use a different name for the help buffer in
 query-replace
Date: Wed, 10 Apr 2019 23:49:45 +0300
> Thanks for testing, Juri.
>
> Since the patch fixes the bug, will it be applied any time soon?

Thanks for the fix, now your patch is pushed to master.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34972; Package emacs. (Wed, 10 Apr 2019 21:03:02 GMT) Full text and rfc822 format available.

Message #25 received at 34972-done <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Juri Linkov <juri <at> linkov.net>, Michał Krzywkowski
 <mkrzywkow <at> gmail.com>
Cc: 34972-done <at> debbugs.gnu.org
Subject: RE: bug#34972: [PATCH] Use a different name for the help buffer in
 query-replace
Date: Wed, 10 Apr 2019 14:02:31 -0700 (PDT)
> > Since the patch fixes the bug, will it be applied any time soon?
> 
> Thanks for the fix, now your patch is pushed to master.

Please consider retitling the bug, as it (the solution, at 
least) is not about renaming the *Help* buffer.

The problem is apparently not the buffer name but the
window, and the  solution seems to be to use a
different window.

(I would likely have objected if the buffer were to
be renamed, rather than a different window being used.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34972; Package emacs. (Thu, 11 Apr 2019 20:59:02 GMT) Full text and rfc822 format available.

Message #28 received at 34972 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Michał Krzywkowski <mkrzywkow <at> gmail.com>,
 34972 <at> debbugs.gnu.org
Subject: Re: bug#34972: [PATCH] Inhibit displaying help buffer in main window
 in perform-replace
Date: Thu, 11 Apr 2019 23:56:51 +0300
[Message part 1 (text/plain, inline)]
retitle 34972 [PATCH] Inhibit displaying help buffer in main window in perform-replace
thanks

> Please consider retitling the bug, as it (the solution, at
> least) is not about renaming the *Help* buffer.

A worse problem is that when 'log-edit-insert-changelog' inserts the author,
it removes the 'log-edit-summary' face from the summary line, this is confusing.
This patch fixes this usability issue by inserting the explicit Summary: field
in case if other fields are inserted:

[log-edit-add-field-summary.patch (text/x-diff, inline)]
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
index 42710dd8dc..ba5a1a3d57 100644
--- a/lisp/vc/log-edit.el
+++ b/lisp/vc/log-edit.el
@@ -754,7 +754,9 @@ log-edit-insert-changelog
 	     (log-edit-insert-changelog-entries (log-edit-files)))))
       (log-edit-set-common-indentation)
       ;; Add an Author: field if appropriate.
-      (when author (log-edit-add-field "Author" (car author)))
+      (when author
+        (log-edit-add-field "Author" (car author))
+        (log-edit-add-field "Summary" ""))
       ;; Add a Fixes: field if applicable.
       (when (consp log-edit-rewrite-fixes)
 	(rfc822-goto-eoh)

Changed bug title to '[PATCH] Inhibit displaying help buffer in main window in perform-replace' from '[PATCH] Use a different name for the help buffer in query-replace' Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Thu, 11 Apr 2019 20:59:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 10 May 2019 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 351 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.