unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Michał Kondraciuk" <k.michal@zoho.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 32278@debbugs.gnu.org
Subject: bug#32278: 27.0.50; replace-buffer-contents calls change functions with wrong arguments
Date: Fri, 27 Jul 2018 13:24:30 +0200	[thread overview]
Message-ID: <1ef81ec1-855d-50fe-e96f-4b3059b6dba6@zoho.com> (raw)
In-Reply-To: <83in51ro16.fsf@gnu.org>

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)))))))))








  reply	other threads:[~2018-07-27 11:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25 16:17 bug#32278: 27.0.50; replace-buffer-contents calls change functions with wrong arguments Michał Kondraciuk
2018-07-27 10:06 ` Eli Zaretskii
2018-07-27 11:24   ` Michał Kondraciuk [this message]
2018-07-27 12:28     ` Eli Zaretskii
2021-08-12 13:30 ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ef81ec1-855d-50fe-e96f-4b3059b6dba6@zoho.com \
    --to=k.michal@zoho.com \
    --cc=32278@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).