[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: yank-handler
From: |
Kim F. Storm |
Subject: |
Re: yank-handler |
Date: |
15 May 2003 01:09:34 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
"Stefan Monnier" <monnier+gnu/address@hidden> 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 <address@hidden> http://www.cua.dk