GNU bug report logs -
#32278
27.0.50; replace-buffer-contents calls change functions with wrong arguments
Previous Next
Reported by: Michał Kondraciuk <k.michal <at> zoho.com>
Date: Thu, 26 Jul 2018 12:06:02 UTC
Severity: normal
Found in version 27.0.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 32278 <at> debbugs.gnu.org (full text, mbox):
> From: Michał Kondraciuk <k.michal <at> zoho.com>
> Date: Wed, 25 Jul 2018 18:17:53 +0200
>
> When I evaluate the sexp below in emacs -Q, I get unexpected arguments
> passed to change functions.
>
> (with-current-buffer "*scratch*"
> (erase-buffer)
> (insert "foo")
>
> (add-hook 'before-change-functions
> (lambda (&rest args) (message "before %s" args)) nil t)
> (add-hook 'after-change-functions
> (lambda (&rest args) (message "after %s" args)) nil t)
>
> (with-temp-buffer
> (insert "ffooo")
> (let ((replacement (current-buffer)))
> (with-current-buffer "*scratch*"
> (replace-buffer-contents replacement)))))
>
> The only messages I get are:
>
> before (4 4)
> after (4 6 0)
>
> I would expect something like:
>
> before (1 1) ;before inserting f in front
> after (1 2 0) ;after inserting f in front
> before (5 5) ;before inserting o at the end
> after (5 6 0) ;after inserting o at the end
>
> Or maybe something like this:
>
> before (1 4)
> after (1 6 3)
>
> Or anything else that would allow me to incrementally build a buffer
> with the same contents as source buffer using just change functions.
Thanks. I just threw away the attempt to be smarter about where the
changes are done, and went back to the original code that announces
changes in the entire region.
If anyone wants to add smarter code, they should do this on master.
This bug report was last modified 3 years and 286 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.