emacs-devel
[Top][All Lists]
Advanced

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

Re: How to get a fixed search string into the editable area of an isearc


From: Juri Linkov
Subject: Re: How to get a fixed search string into the editable area of an isearch.
Date: Sun, 05 Jun 2016 00:46:49 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (x86_64-pc-linux-gnu)

> I have a need for a command that starts an isearch with a specific string
> in the editable area that I can add and subtract characters from
> interactively during the search.  I have things working with the following
> code except the string does not appear in the editable area even though the
> search is done for the fixed string.  Can anyone solve this?  I couldn't
> get any of the isearch-yank-* commands to do the right thing here either.
> Please help.  Thanks.
>
> It would be much simpler if the user-level isearch commands like
> isearch-forward could take a string/regexp as an argument and then jump
> into the middle of a search as if the characters had been typed
> interactively.  One might think setting isearch-string would do something
> similar.
>
> (defun isearch-for-string ()
>   "Interactively search forward for next occurrence of a fixed string.
> Then add characters to further narrow the search."
>   (interactive)
>   (let* ((match-str "fixed-string")
>          (isearch-mode-hook
>  (append '((lambda () (interactive) (setq isearch-string match-str))
>    isearch-mode-hook))))
>     (if (not (equal match-str (car search-ring)))
> (isearch-update-ring match-str nil))
>     (isearch-forward)))

Maybe this is what you need?

  (defun isearch-for-string ()
    (interactive)
    (isearch-forward nil 1)
    (isearch-yank-string "test"))



reply via email to

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