emacs-devel
[Top][All Lists]
Advanced

[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: Juri Linkov
Subject: Re: yank-match.el -- yank matches for a regexp from kill-ring
Date: Tue, 04 Mar 2008 02:35:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-unknown-linux-gnu)

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

Modifying `yank-pop' in simple.el to take into account the initial
command `yank-match' has also benefits of using the recent and more
correct code to do this.  For instance, your command uses `delete-region'
to replace the previously-yanked text, but `yank-pop' has more advanced
code that calls (funcall (or yank-undo-function 'delete-region) ...)

Also your command uses `insert' to insert the previously-yanked text,
but `yank-pop' uses `insert-for-yank' to strip text properties from the
inserted text according to `yank-excluded-properties'.  I guess your patch
was written when there was no such functions in Emacs?

I think it would be safer to reuse code in `yank-pop' and just find
places in it that differ from `yank-match' functionality, like
`current-kill'.  Maybe you could just add a new match-string argument
to `current-kill' that will rotate the yanking point by N matching
places?

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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