[Top][All Lists]

[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: Michael Heerdegen
Subject: Re: How to get a fixed search string into the editable area of an isearch.
Date: Thu, 02 Jun 2016 00:21:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.94 (gnu/linux)

Robert Weiner <address@hidden> writes:

> 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.

I'm just a user like you, but figured out some missing elements I think.
Try this:

#+begin_src emacs-lisp
(defun my-isearch-for-string ()
  (let ((isearch-mode-hook
         (cons (lambda ()
                 (setq isearch-string "test"
                       isearch-message "test"
                       isearch-yank-flag t)

You probably want to add your updating of the search ring and other

AFAICT, the text displayed in the minibuffer is (based on) the current
binding of the variable `isearch-message', and it is up to you to update
it properly (it doesn't happen automatically).

`isearch-search-and-update' triggers, yes, what it says.

I'm not sure why isearch-yank-flag -> t was useful, a comment in my code

|    ;; Don't move cursor in reverse search.

BTW, in your code:

#+begin_src emacs-lisp
(let* ((match-str "fixed-string")
        (append '((lambda () (interactive) (setq isearch-string match-str)))

there is a quoted lambda; it's better to avoid quoted lambdas for
several reasons.



reply via email to

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