emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it valid to call isearch-filter-predicate outside isearch?


From: Michael Heerdegen
Subject: Re: Is it valid to call isearch-filter-predicate outside isearch?
Date: Sun, 18 Jun 2023 04:48:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Ihor Radchenko <yantar92@posteo.net> writes:

> >> May you please elaborate? I am not sure what `kill-variable' calls you
> >> are referring to here.
> >
> > To those in `wdired-change-to-dired-mode:
> >
> > #+begin_src emacs-lisp
> >   (when wdired-search-replace-filenames
> >     (remove-function (local 'isearch-search-fun-function)
> >                      #'dired-isearch-search-filenames)
> >     (kill-local-variable 'replace-search-function)
> >     (kill-local-variable 'replace-re-search-function)
> >     ;; Restore dired hook
> >     (add-hook 'isearch-mode-hook #'dired-isearch-filenames-setup nil t))
> > #+end_src
> >
> > This demonstrates a problem when not using an advice: to get rid of the
> > temporary new binding you simply kill the local variable, but this can
> > be problematic, especially when we did not create it (but maybe someone
> > third).
>
> The code above is indeed slightly problematic.
> I'd store the old value somewhere in such situations and restore later.

Now I'm a bit confused.  Is advising not exactly the perfect solution
for that problem because it allows to avoid explicit saving and
restoring (which is one reason why I'm suggesting to use advising, plus:
overlapping modification and restore operations don't collide), and:

> May `define-advice' be modified to work on variable values? That way,
> one can override the variable value and later restore the old one using
> the existing machinery.

What's wrong with `add-function' and `remove-function' (which work on
variable values)?

Seems you misunderstood what I'm suggesting, or you misunderstand how
advising works.

Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]