[Top][All Lists]

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

PATCH: isearch-yank-until-match

From: Drew Adams
Subject: PATCH: isearch-yank-until-match
Date: Wed, 14 Aug 2019 14:08:50 -0700 (PDT)

This is similar to what Karl submitted today.
Not a replacement for that; something different.


During Isearch, hit `C-M-m' (aka `M-RET').
You're prompted for another search pattern.
The text matching the pattern from point,
in the search direction, is yanked to the
search string.

Works for forward and backward searches,
and for regexp and literal searches.

If searching backward, the matched text is
prepended to the search string; else it is

If you use a prefix arg with `C-M-m' then
the pattern is matched as a regexp, not


I think Karl's `isearch-yank-until-char'
should also be made to support backward

With the attached patch the following
definition does that.  (The attached
patch does not include this command.
The diff is against the isearch.el in
master today.)

(defun isearch-yank-until-char (char)
  "Yank buffer text, up to next instance of CHAR, to search string.
You are prompted for CHAR."
  (interactive "cYank until character: ")
   (lambda ()
     (let ((inhibit-field-text-motion t))
       (funcall (if isearch-forward
                (char-to-string char))
       (if isearch-forward


The attached patch also improves these
two functions:


Prepend STRING if searching backward and
search string is not just a single char.
(Otherwise, append, as now.)

Add a doc string.


1. Doc string now talks about arg as being
a function, not a "lambda expression".
Arg name is JUMPFUN, not JUMPFORM.

2. Use fixed version of
`isearch-process-search-string', so no
need to move to other end when searching


I don't think the patch breaks anything
(e.g. uses of `isearch-yank-internal' or
`isearch-process-search-string'), but
I've done limited testing.  Maybe someone
knowledgeable about the isearch.el code
(e.g. Juri) could take a look to be sure.

Attachment: isearch-2019-08-14a.patch
Description: Binary data

reply via email to

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