|
| From: | martin rudalics |
| Subject: | Re: before-change-functions called twice at yank |
| Date: | Tue, 11 Apr 2006 08:58:26 +0200 |
| User-agent: | Mozilla Thunderbird 1.0 (Windows/20041206) |
Do emacs -q and evaluate
(progn
(add-hook 'before-change-functions
(lambda (b e)
(message "before-change: '%s'" (buffer-substring b e))) nil t)
(add-hook 'after-change-functions
(lambda (b e l)
(message "after-change: '%s'" (buffer-substring b e))) nil t))
in the *scratch* buffer. If you press the letter a, the message buffer
will get
before-change: ''
after-change: 'a'
as expected. Now yank the string "foo". Then the message buffer gets
before-change: ''
after-change: 'foo'
before-change: 'foo'
This seems as a bug to me. Am I missing something?
Indeed you should see another message from `after-change-functions' like:
before-change: ''
after-change: 'foo'
before-change: 'foo'
after-change: 'foo'
The last two messages are due to `remove-yank-excluded-properties' which
removes `yank-excluded-properties' from the string inserted. You can
avoid running the hooks either by doing
(let ((inhibit-read-only t)
(inhibit-modification-hooks t))
in `remove-yank-excluded-properties' directly or by wrapping the calls to
`remove-yank-excluded-properties' in `insert-for-yank-1' (and possibly
`insert-buffer-substring-as-yank') as
(let ((inhibit-modification-hooks t))
(remove-yank-excluded-properties opoint (point)))
| [Prev in Thread] | Current Thread | [Next in Thread] |