[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: isearch-lax question error?
From: |
Philip Kaludercic |
Subject: |
Re: isearch-lax question error? |
Date: |
Thu, 04 Apr 2024 05:07:58 +0000 |
Ergus <spacibba@aol.com> writes:
> Hi:
>
> I am trying to create a lax isearch interactive that use ".*?" but
> independent from the default one very useful as well.
>
> I already have isearch-lax-whitespace and search-whitespace-regexp to
> the defaults.
>
> And in my function I only want to change search-spaces-regexp in order
> to make the command temporarily more flexible.
>
> so far I have something simple like this:
>
> (defun my/isearch-forward ()
> (interactive)
> (let ((search-spaces-regexp ".*?")) ;; I alternated this with
> search-whitespace-regexp
> (call-interactively 'isearch-forward)))
>
> However this does not behave as expected; it changes nothing compared to
> the default behavior.
>
> But If I set (defcustom isearch-lax-whitespace ".*?") then I get the
> right behavior in the normal isearch-forward.
>
> What I am missing here?
isearch-forward enabled isearch-mode, and then returns. The dynamic
binding of search-spaces-regexp will not be in effect anymore, when the
actual searching is taking place (recall that isearch doesn't take over
the event-loop, but just rebinds commands: "a" which is usually bound to
`self-insert-command' is rebound to `isearch-printing-char').
So what you would need, might be something like this
--8<---------------cut here---------------start------------->8---
(defun my/isearch-forward ()
(interactive)
(letrec ((hook 'isearch-mode-end-hook)
(reset (lambda () (remove-hook hook reset t))))
(add-hook hook reset nil t)
(setq-local search-spaces-regexp ".*?")
(call-interactively #'isearch-forward)))
--8<---------------cut here---------------end--------------->8---
(not tested extensivly)
> Thanks in advance,
> Ergus
>
>
>
--
Philip Kaludercic on peregrine