GNU bug report logs - #32278
27.0.50; replace-buffer-contents calls change functions with wrong arguments

Previous Next

Package: emacs;

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 #11 received at 32278 <at> debbugs.gnu.org (full text, mbox):

From: Michał Kondraciuk <k.michal <at> zoho.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 32278 <at> debbugs.gnu.org
Subject: Re: bug#32278: 27.0.50; replace-buffer-contents calls change
 functions with wrong arguments
Date: Fri, 27 Jul 2018 13:24:30 +0200
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)))
    (with-temp-buffer
      (insert text)
      (let ((replacement (current-buffer)))
        (with-current-buffer source
          (save-restriction
            (widen)
            (narrow-to-region beg end)
            (let ((inhibit-modification-hooks t))
              (run-hook-with-args 'before-change-functions beg end)
              (replace-buffer-contents replacement)
              (run-hook-with-args 'after-change-functions beg
                                  (+ beg (length text)) (- end beg)))))))))







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.