all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Robert Weiner <rswgnu@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
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	[thread overview]
Message-ID: <871t4cd58e.fsf@mail.linkov.net> (raw)
In-Reply-To: <CA+OMD9hLPEhMD6a3hYdWNoPSkFvgdmJuaktU+KkeBKJ+JihxHQ@mail.gmail.com> (Robert Weiner's message of "Tue, 31 May 2016 15:13:40 -0400")

> 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"))



  parent reply	other threads:[~2016-06-04 21:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31 19:13 How to get a fixed search string into the editable area of an isearch Robert Weiner
2016-06-01  5:07 ` Tom
2016-06-01 22:21 ` Michael Heerdegen
2016-06-04 21:46 ` Juri Linkov [this message]
2016-06-04 22:42   ` Robert Weiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871t4cd58e.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=emacs-devel@gnu.org \
    --cc=rswgnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.