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: Ihor Radchenko
Subject: Re: Is it valid to call isearch-filter-predicate outside isearch?
Date: Sat, 17 Jun 2023 13:05:52 +0000

Michael Heerdegen <michael_heerdegen@web.de> 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.

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.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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