unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Visuwesh <visuweshm@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: Michael Heerdegen <michael_heerdegen@web.de>, 72147@debbugs.gnu.org
Subject: bug#72147: 30.0.60; 30.0.60; Misleading regexp highlighting in 'Q' dired command
Date: Sun, 28 Jul 2024 10:29:05 +0530	[thread overview]
Message-ID: <87r0bei02u.fsf@gmail.com> (raw)
In-Reply-To: <8634nxjv0l.fsf@mail.linkov.net> (Juri Linkov's message of "Thu,  25 Jul 2024 21:08:42 +0300")

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

[வியாழன் ஜூலை 25, 2024] Juri Linkov wrote:

>>> > Wouldn't it be better to add a new optional argument NO-HIGHLIGHT to
>>> > `query-replace-read-args', for stylistic reasons?
>>>
>>> It's not clear how such arg should be combined with
>>> `query-replace-lazy-highlight' in `query-replace-read-args':
>>>
>>> (defun query-replace-read-args (prompt regexp-flag &optional noerror no-highlight)
>>>   ...
>>>   (from (minibuffer-with-setup-hook
>>>             (minibuffer-lazy-highlight-setup
>>>              :highlight query-replace-lazy-highlight
>>>
>>> with `and'?  With `or'?  With `xor'?
>>> `(and query-replace-lazy-highlight (not no-highlight))'?
>>
>> The installed patch binds query-replace-lazy-highlight to nil and
>> shadows the old binding.  This would correspond to
>>
>>   (and query-replace-lazy-highlight (not no-highlight))
>>
>> which looks reasonable in this case: we just an argument to inhibit
>> highlighting.  Because we never want highlighting in some cases (like
>> here).
>
> Agreed, let's add a new argument.

So how about the attached patch?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-new-optional-argument-NO-HIGHLIGHT-to-query-repl.patch --]
[-- Type: text/x-diff, Size: 3468 bytes --]

From 17a6b4e86887235fcd5ab324ffab1d26eb90612f Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
Date: Sun, 28 Jul 2024 10:27:33 +0530
Subject: [PATCH] Add new optional argument NO-HIGHLIGHT to
 query-replace-read-args

* lisp/replace.el (query-replace-read-args): Add new optional
argument to disable regexp highlighting.

* lisp/dired-aux.el (dired-do-query-replace-regexp)
(dired-do-replace-regexp-as-diff)
(dired-do-find-regexp-and-replace): Revert last change, and use
the new argument instead.  (bug#72147)
---
 lisp/dired-aux.el | 19 ++++++++-----------
 lisp/replace.el   |  4 ++--
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index decd9702eaf..cd948bd7dd9 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -3801,10 +3801,9 @@ 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* ((query-replace-lazy-highlight)
-          (common
-	   (query-replace-read-args
-	    "Query replace regexp in marked files" t t)))
+   (let ((common
+	  (query-replace-read-args
+	   "Query replace regexp in marked files" t 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))
@@ -3826,10 +3825,9 @@ 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* ((query-replace-lazy-highlight)
-          (common
-           (query-replace-read-args
-            "Replace regexp as diff in marked files" t t)))
+   (let ((common
+          (query-replace-read-args
+           "Replace regexp as diff in marked files" t t t)))
      (list (nth 0 common) (nth 1 common) (nth 2 common))))
   (dired-post-do-command)
   (multi-file-replace-regexp-as-diff
@@ -3903,10 +3901,9 @@ dired-do-find-regexp-and-replace
 Also see `query-replace' for user options that affect how this
 function works."
   (interactive
-   (let* ((query-replace-lazy-highlight)
-          (common
+   (let ((common
           (query-replace-read-args
-           "Query replace regexp in marked files" t t)))
+           "Query replace regexp in marked files" t t t)))
      (list (nth 0 common) (nth 1 common)))
    dired-mode)
   (require 'xref)
diff --git a/lisp/replace.el b/lisp/replace.el
index 01a892bbba7..2285b19b519 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -352,7 +352,7 @@ query-replace-read-to
        to))
    regexp-flag))
 
-(defun query-replace-read-args (prompt regexp-flag &optional noerror)
+(defun query-replace-read-args (prompt regexp-flag &optional noerror no-highlight)
   (unless noerror
     (barf-if-buffer-read-only))
   (save-mark-and-excursion
@@ -364,7 +364,7 @@ query-replace-read-args
                       :filter (when (use-region-p)
                                 (replace--region-filter
                                  (funcall region-extract-function 'bounds)))
-                      :highlight query-replace-lazy-highlight
+                      :highlight (and query-replace-lazy-highlight (not no-highlight))
                       :regexp regexp-flag
                       :regexp-function (or replace-regexp-function
                                            delimited-flag
-- 
2.45.2


  reply	other threads:[~2024-07-28  4:59 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
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 [this message]
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=87r0bei02u.fsf@gmail.com \
    --to=visuweshm@gmail.com \
    --cc=72147@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=michael_heerdegen@web.de \
    /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).