From: Visuwesh <visuweshm@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: 72147@debbugs.gnu.org
Subject: bug#72147: 30.0.60; 30.0.60; Misleading regexp highlighting in 'Q' dired command
Date: Fri, 19 Jul 2024 13:55:24 +0530 [thread overview]
Message-ID: <87r0bpu6tn.fsf@gmail.com> (raw)
In-Reply-To: <86le1xkh8w.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 19 Jul 2024 09:50:23 +0300")
[-- Attachment #1: Type: text/plain, Size: 1530 bytes --]
[வெள்ளி ஜூலை 19, 2024] Juri Linkov wrote:
>> When using the Q command in dired to query-replace-regexp across marked
>> files in dired, the regexp typed in the first prompt highlights text in
>> the _dired_ buffer.
>>
>> To reproduce,
>>
>> 1. emacs -Q
>> 2. C-x d ~
>> 3. Q -
>>
>> Notice how the dashes in the permission fields are highlighted. This is
>> misleading and even confusing. It would be better to turn off regexp
>> highlighting for this command. The attached patch does the job on my
>> end. Let binding the variable this way does not turn off
>> lazy-highlighting during the replacement.
>>
>> @@ -3801,9 +3801,10 @@ dired-do-query-replace-regexp
>> (interactive
>> - (let ((common
>> - (query-replace-read-args
>> - "Query replace regexp in marked files" t t)))
>> + (let* ((query-replace-lazy-highlight)
>> + (common
>> + (query-replace-read-args
>> + "Query replace regexp in marked files" t t)))
>
> Thanks, I tried your patch, but it has no effect since
> by default Q is bound to dired-do-find-regexp-and-replace.
Ah, I guess I didn't test properly in emacs -Q. I ended up mixing my
own config and emacs -Q. My bad.
> Shouldn't query-replace-lazy-highlight be added to all
> functions in dired that use query-replace-read-args?
Yes, you're right. I have attached a patch that does it.
BTW, is there a reason why xref--query-replace-1 let-binds
query-replace-lazy-highlight to nil?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-highlight-matches-in-dired-query-replace-comma.patch --]
[-- Type: text/x-diff, Size: 2295 bytes --]
From b2c7a4deafd505c18a0907fb86b86763f007e85c Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
Date: Wed, 17 Jul 2024 09:11:04 +0530
Subject: [PATCH] Don't highlight matches in dired query-replace commands
* lisp/dired-aux.el (dired-do-query-replace-regexp)
(dired-do-replace-regexp-as-diff)
(dired-do-find-regexp-and-replace): Turn off lazy highlighting
when reading the regexp from the user to avoid highlighting
regexp matches in the dired buffer. (bug#72147)
---
lisp/dired-aux.el | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index e06e36aaa75..decd9702eaf 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -3801,9 +3801,10 @@ dired-do-query-replace-regexp
If you exit the query-replace loop (\\[keyboard-quit], RET or q), you can
resume the query replace with the command \\[fileloop-continue]."
(interactive
- (let ((common
- (query-replace-read-args
- "Query replace regexp in marked files" t t)))
+ (let* ((query-replace-lazy-highlight)
+ (common
+ (query-replace-read-args
+ "Query replace regexp in marked files" t t)))
(list (nth 0 common) (nth 1 common) (nth 2 common)))
dired-mode)
(dolist (file (dired-get-marked-files nil nil #'dired-nondirectory-p nil t))
@@ -3825,9 +3826,10 @@ dired-do-replace-regexp-as-diff
The replacements are displayed in the buffer *replace-diff* that
you can later apply as a patch after reviewing the changes."
(interactive
- (let ((common
- (query-replace-read-args
- "Replace regexp as diff in marked files" t t)))
+ (let* ((query-replace-lazy-highlight)
+ (common
+ (query-replace-read-args
+ "Replace regexp as diff in marked files" t t)))
(list (nth 0 common) (nth 1 common) (nth 2 common))))
(dired-post-do-command)
(multi-file-replace-regexp-as-diff
@@ -3901,7 +3903,8 @@ dired-do-find-regexp-and-replace
Also see `query-replace' for user options that affect how this
function works."
(interactive
- (let ((common
+ (let* ((query-replace-lazy-highlight)
+ (common
(query-replace-read-args
"Query replace regexp in marked files" t t)))
(list (nth 0 common) (nth 1 common)))
--
2.45.2
next prev parent reply other threads:[~2024-07-19 8:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-17 3:43 bug#72147: 30.0.60; 30.0.60; Misleading regexp highlighting in 'Q' dired command Visuwesh
2024-07-19 6:50 ` Juri Linkov
2024-07-19 8:25 ` Visuwesh [this message]
2024-07-23 6:37 ` Juri Linkov
2024-07-23 9:27 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-23 17:40 ` Juri Linkov
2024-07-24 17:09 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-25 18:08 ` Juri Linkov
2024-07-28 4:59 ` Visuwesh
2024-07-28 6:54 ` 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=87r0bpu6tn.fsf@gmail.com \
--to=visuweshm@gmail.com \
--cc=72147@debbugs.gnu.org \
--cc=juri@linkov.net \
/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).