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

* bug#34972: [PATCH] Use a different name for the help buffer in query-replace
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2019-03-31 20:11 UTC (permalink / raw)
  To: Michał Krzywkowski; +Cc: 34972

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





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

* bug#34972: [PATCH] Use a different name for the help buffer in query-replace
  2019-03-31 20:11 ` Juri Linkov
@ 2019-04-01  9:12   ` Michał Krzywkowski
  2019-04-01 20:07     ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Michał Krzywkowski @ 2019-04-01  9:12 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Michał Krzywkowski, 34972


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


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?


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

From c3a1806b355228b28b70ddce716b6f578e9eacb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Krzywkowski?= <k.michal@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



[-- Attachment #1.3: Type: text/plain, Size: 83 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

* bug#34972: [PATCH] Use a different name for the help buffer in query-replace
  2019-04-01  9:12   ` Michał Krzywkowski
@ 2019-04-01 20:07     ` Juri Linkov
  2019-04-10 13:07       ` Michał Krzywkowski
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2019-04-01 20:07 UTC (permalink / raw)
  To: Michał Krzywkowski; +Cc: 34972

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





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

* bug#34972: [PATCH] Use a different name for the help buffer in query-replace
  2019-04-01 20:07     ` Juri Linkov
@ 2019-04-10 13:07       ` Michał Krzywkowski
  2019-04-10 20:49         ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Michał Krzywkowski @ 2019-04-10 13:07 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Michał Krzywkowski, 34972

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


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


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

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

* bug#34972: [PATCH] Use a different name for the help buffer in query-replace
  2019-04-10 13:07       ` Michał Krzywkowski
@ 2019-04-10 20:49         ` Juri Linkov
  2019-04-10 21:02           ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2019-04-10 20:49 UTC (permalink / raw)
  To: Michał Krzywkowski; +Cc: 34972-done

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





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

* bug#34972: [PATCH] Use a different name for the help buffer in query-replace
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2019-04-10 21:02 UTC (permalink / raw)
  To: Juri Linkov, Michał Krzywkowski; +Cc: 34972-done

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





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

* bug#34972: [PATCH] Inhibit displaying help buffer in main window in perform-replace
  2019-04-10 21:02           ` Drew Adams
@ 2019-04-11 20:56             ` Juri Linkov
  0 siblings, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2019-04-11 20:56 UTC (permalink / raw)
  To: Drew Adams; +Cc: Michał Krzywkowski, 34972

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

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: log-edit-add-field-summary.patch --]
[-- Type: text/x-diff, Size: 628 bytes --]

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)

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