Subject: 30.0.60; 30.0.60; Misleading regexp highlighting in 'Q' dired command

From: Visuwesh <[email-masked]>
Date: Wed, 17 Jul 2024 09:13:07 +0530

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.

>From 35f06221023133708f228167f88eb5350ba84dde Mon Sep 17 00:00:00 2001
From: Visuwesh <[email-masked]>
Date: Wed, 17 Jul 2024 09:11:04 +0530
Subject: [PATCH] Don't highlight regexp matches when using dired Q command

* lisp/dired-aux.el (dired-do-query-replace-regexp): Turn off
lazy highlighting when reading the regexp from the user to avoid
highlighting regexp matches in the dired buffer.
---
 lisp/dired-aux.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index e06e36aaa75..8029074d5a4 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))
-- 
2.45.2

In GNU Emacs 30.0.60 (build 5, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.18.0, Xaw scroll bars) of 2024-07-10 built on astatine
Repository revision: 5cf8d60e0dec5606a94749d17a5d678455b7a437
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12101011
System Description: Debian GNU/Linux trixie/sid

Configured using:
 'configure --with-sound=alsa --with-x-toolkit=lucid --without-xaw3d
 --without-gconf --without-libsystemd --with-cairo'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM
XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LC_MONETARY: ta_IN.UTF-8
  value of $LC_NUMERIC: ta_IN.UTF-8
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
xinput2 x multi-tty move-toolbar make-network-process emacs)

Memory information:
((conses 16 41209 13476) (symbols 48 5821 0) (strings 32 14271 1663)
 (string-bytes 1 317312) (vectors 16 9302)
 (vector-slots 8 110789 8365) (floats 8 23 3) (intervals 56 256 1)
 (buffers 984 10))