From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: yank-handler
Date: 15 May 2003 01:09:34 +0200 [thread overview]
Message-ID: <5x1xz13z2p.fsf@kfs2.cua.dk> (raw)
In-Reply-To: <200305141603.h4EG3HZW017616@rum.cs.yale.edu>
"Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:
> I'd like to get diff-mode to behave as follows:
>
> If I kill a piece of a hunk and then yank it in some other buffer,
> the "[+-! ]" prefix added to each and every line should be removed
> (unless I'm yanking back into a diff-mode buffer or unless there's
> something like a "@@ -463,4 +463,36 @@" marker, obviously).
>
> I'm still not quite sure whether it's a good idea or not, but to
> figure that out, I'd like to experiment with it, but I can't seem
> to figure out how to do it.
>
> More specifically, it seems that the yank-handler property can only be
> set by passing the proper argument to `kill-new' (or one
> of its front men). Is that right ? Why is that ?
Because that was the context in which the idea was conceived (e.g.
for a mode like table-mode where a keymap property on text in a table
cell (but not on the buffer as a whole) would remap kill-region
etc. to table-kill-region etc. which would set the proper yank-handler
for yanking killed table contents in some sensible manner.
> I don't want to rebind C-k, C-w, M-w and whatnot just to do that.
> I'd rather either put the property directly on the text, or set
> some buffer-local `default-yank-handler-for-kill' variable.
I like the simplicity of having a buffer-local
default-yank-handler-for-kill variable (default nil).
I guess it would also work by having the yank-handler property
directly on the text in the buffer; especially since that property is
supposed to be removed automatically when the text is yanked into the
buffer (see insert-for-yank).
>
> Any comment ?
Feel free to go ahead and improve the yank-handler functionality.
I think those changes can be localized to kill-new and kill-append
like this:
- In `kill-new' and `kill-append' add this at the beginning:
(unless yank-handler
(setq yank-handler default-yank-handler-for-kill))
- In `kill-new', simply remove this "else part" in the second if:
(remove-list-of-text-properties 0 1 '(yank-handler) string))
Your new functionality for diff-mode will be a good "proof of concept".
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
next prev parent reply other threads:[~2003-05-14 23:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-14 16:03 yank-handler Stefan Monnier
2003-05-14 23:09 ` Kim F. Storm [this message]
2003-05-15 15:42 ` yank-handler Richard Stallman
2003-05-15 16:19 ` yank-handler Andreas Schwab
-- strict thread matches above, loose matches on Subject: below --
2004-02-13 3:52 yank-handler Luc Teirlinck
2004-02-13 4:09 ` yank-handler Luc Teirlinck
2004-02-13 16:15 ` yank-handler Kim F. Storm
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=5x1xz13z2p.fsf@kfs2.cua.dk \
--to=storm@cua.dk \
--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).