[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#32278: 27.0.50; replace-buffer-contents calls change functions with
bug#32278: 27.0.50; replace-buffer-contents calls change functions with wrong arguments
Fri, 27 Jul 2018 13:24:30 +0200
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
On 07/27/2018 12:06 PM, Eli Zaretskii wrote:
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.
Thanks. Can you tell me if the workaround below (calling change functions manually) is
correct/safe for emacs versions where this is not fixed? It's a function that
non-destructively replaces region contents.
(defun my-replace-region (beg end text)
"Replace region BEG END with TEXT.
As far as possible the replacement is non-destructive."
(let ((source (current-buffer)))
(let ((replacement (current-buffer)))
(narrow-to-region beg end)
(let ((inhibit-modification-hooks t))
(run-hook-with-args 'before-change-functions beg end)
(run-hook-with-args 'after-change-functions beg
(+ beg (length text)) (- end beg)))))))))