GNU bug report logs - #53126
29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc.

Previous Next

Package: emacs;

Reported by: Augusto Stoffel <arstoffel <at> gmail.com>

Date: Sat, 8 Jan 2022 13:25:01 UTC

Severity: normal

Tags: patch

Merged with 53341

Fixed in version 29.0.50

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

Bug is archived. No further changes may be made.

Full log


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

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 53126 <at> debbugs.gnu.org
Subject: Re: bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading
 query-replace string, etc.
Date: Mon, 04 Apr 2022 19:37:10 +0300
> I've attached a sketch of a macro to help activating the minibuffer lazy
> highlight.  It doesn't make query-replace-read-args exactly short, but
> if you like this, I can prepare the patch.

I realized we already have the macro minibuffer-with-setup-hook,
so we don't need more macros.

The purpose of minibuffer-with-setup-hook is to set up the minibuffer
to the initial state with buffer-local variables.  In case of
lazy-highlighting, we can't set isearch variables directly,
but all isearch variables can be replaced by one variable
that contains a set of lazy-highlight parameters.  For example:

  (minibuffer-with-setup-hook
      (lambda ()
        (setq-local lazy-highlight-params
                    `((case-fold ,case-fold-search)
                      (regexp ,regexp-flag)
                      (regexp-function ,(or replace-regexp-function
                                            (and current-prefix-arg
                                                 (not (eq current-prefix-arg '-)))
                                            (and replace-char-fold
                                                 (not regexp-flag)
                                                 #'char-fold-to-regexp)))))
        (minibuffer-lazy-highlight-init))
    (query-replace-read-from prompt regexp-flag))

where minibuffer-lazy-highlight-init does a little more than
minibuffer-lazy-highlight-setup.  Or maybe it's not needed,
and minibuffer-lazy-highlight-setup should be enough.
Or maybe instead of setq-local is can let-bind variables.

Please also note that condition-case can be replaced by
a hook in minibuffer-exit-hook that can remove highlighting
after exiting the minibuffer.

Alternatively, the same lambda above could be added to

  (add-hook 'minibuffer-setup-hook (lambda () ...))




This bug report was last modified 3 years and 39 days ago.

Previous Next


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