unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Weiner <rswgnu@gmail.com>
To: emacs-devel <emacs-devel@gnu.org>
Subject: How to get a fixed search string into the editable area of an isearch.
Date: Tue, 31 May 2016 15:13:40 -0400	[thread overview]
Message-ID: <CA+OMD9hLPEhMD6a3hYdWNoPSkFvgdmJuaktU+KkeBKJ+JihxHQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]

Hi:

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

[-- Attachment #2: Type: text/html, Size: 1585 bytes --]

             reply	other threads:[~2016-05-31 19:13 UTC|newest]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CA+OMD9hLPEhMD6a3hYdWNoPSkFvgdmJuaktU+KkeBKJ+JihxHQ@mail.gmail.com \
    --to=rswgnu@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).