From: Juri Linkov <juri@jurta.org>
To: Karl Fogel <kfogel@red-bean.com>
Cc: emacs-devel@gnu.org
Subject: Re: yank-match.el -- yank matches for a regexp from kill-ring
Date: Tue, 04 Mar 2008 02:35:31 +0200 [thread overview]
Message-ID: <87ablffho4.fsf@jurta.org> (raw)
In-Reply-To: <87tzjowus6.fsf@red-bean.com> (Karl Fogel's message of "Sun, 02 Mar 2008 18:50:01 -0500")
>> 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/
next prev parent reply other threads:[~2008-03-04 0:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-15 23:38 yank-match.el -- yank matches for a regexp from kill-ring Karl Fogel
2007-07-17 18:44 ` Mathias Dahl
2007-07-17 18:46 ` Karl Fogel
2007-07-17 19:29 ` Drew Adams
2007-07-17 20:40 ` Mathias Dahl
2007-07-28 20:32 ` T. V. Raman
2008-03-02 16:17 ` Karl Fogel
2008-03-02 17:59 ` Juri Linkov
2008-03-02 19:25 ` Stefan Monnier
2008-03-02 20:07 ` Juri Linkov
2008-03-02 23:50 ` Karl Fogel
2008-03-04 0:35 ` Juri Linkov [this message]
2008-03-04 1:16 ` Karl Fogel
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=87ablffho4.fsf@jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
--cc=kfogel@red-bean.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 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).