[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: yank-match.el -- yank matches for a regexp from kill-ring
From: |
Karl Fogel |
Subject: |
Re: yank-match.el -- yank matches for a regexp from kill-ring |
Date: |
Sun, 02 Mar 2008 18:50:01 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) |
Juri Linkov <address@hidden> writes:
> May I make some remarks? Usually a good function is harder to find
> in a separate small file. Also it is more difficult to incorporate a
> separate file into the core functionality. But this would be useful:
> when I tried using your `yank-match' at the first try it yanked the
> first match but I needed one of the next matches. Then I typed M-y
> to cycle next matches, but this method failed. I think just like a
> sequence of `C-y M-y M-y M-y' cycles the kill-ring it would be good to
> do the same for `yank-match' as `M-x yank-match RET regexp RET M-y M-y'
> to cycle matches from the kill-ring.
Thank you, this is a good idea.
Repeated invocations of `yank-match' will have this effect. It never
occurred to me to make M-y DTRT, but it seems obvious in retrospect:
M-y (that is, `yank-pop') should cycle through the kill-ring in the
usual way if the initial command was `yank', but cycle matches if the
initial command was `yank-match'.
> BTW, I have a command for similar purposes:
>
> (defun insert-yank-from-kill-ring (string)
> "Insert the selected item from the kill-ring in the minibuffer history.
> Use minibuffer navigation and search commands to browse the kill-ring
> in the minibuffer history."
> (interactive (list (read-string "Yank from kill-ring: " nil 'kill-ring)))
> (insert-for-yank string))
>
> Comparing to your approach, it has one drawback: multi-line elements
> in the kill-ring will resize the minibuffer, but in other respects
> those are complementing approaches.
Yes, that seems useful -- but big matches have a problem, as you
pointed out. Also, sometimes one just knows the right regexp (usually
just a substring), in which case `yank-match' is the fastest way to
get there.
Stefan Monnier <address@hidden> writes:
> Your file uses ";;;" incorrectly. Most of those should be ";;" (the
> ";;;" should be used to separate sections).
*nod* Can fix.
> But in any case, there's no need for a separate file for such
> a small function.
Okay. Shall I make the changes Juri suggests above re M-y, and put
both the `yank-match' code and his code above into simple.el?
-Karl