>>> + (defvar before-kill-functions nil
>>> +   "List of functions called on the region before killing.
>>> + This abnormal hook is run before `kill-region' and
>>> + `copy-region-as-kill', with the beginning and end positions of
>>> + the killed region as the arguments.")
>> 
>> I think it's usually important to keep the property that killing doesn't
>> modify the buffer's text (when used in copy-as-kill), so rather than having
>> before-kill-functions modify the buffer's text just before it's put in the
>> kill-ring, it would be more convenient to make it return the string,
>> i.e. use it as a replacement for buffer-substring.

> I like the idea, but returning a value from a hook is rather
> inconvenient -- if there are multiple functions on the hook, which
> value should you use eventually?

> Perhaps before-kill-functions should get START, END and STRING
> as arguments where STRING is the result of buffer-substring.

> Each hook could then modify that string as they please.

Fair enough.

> Or perhaps a different approach:
> Run after-kill-hooks (a normal hook!) as the last thing in kill-region
> and copy-region-as-kill, i.e. after putting the string into
> the kill-ring.  If necessary, the hooks can modify the head of
> the kill-ring as they please...?

I'm not sure if that would be reliable: the head of kill-ring might be the
result of concatenating the old head and the new text, where the old head
has already been processed by after-kill-hook, but you can't tell which part
is the old one and which part is the new one.


        Stefan


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

Reply via email to