Subject: bug#36190: closed (Re: bug#36190: 27.0.50; `put-text-property' etc. with buffer argument calls current buffer's `after-change-functions')

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 06 Jul 2019 16:23:02 +0000

Your bug report

#36190: 27.0.50; `put-text-property' etc. with buffer argument calls current buffer's `after-change-functions'

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
36190: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=36190
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#36190: 27.0.50; `put-text-property' etc. with buffer argument calls current buffer's `after-change-functions'
From: Eli Zaretskii <[email-masked]>
To: Pip Cet <[email-masked]>
Cc: [email-masked]
Date: Sat, 06 Jul 2019 19:22:32 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Pip Cet <[email-masked]>
> Date: Sat, 6 Jul 2019 15:27:41 +0000
> Cc: [email-masked]
> 
> > LGTM, with a couple of minor comments below.  Feel free to push after
> > fixing those.
> 
> I don't have push access, so I hope it's okay just to send the new patch.

Thanks, pushed.  Please in the future mention the bug number in the
log message, and be sure NOT to end with a period the header line of
the log message, per CONTRIBUTE.

Subject: 27.0.50; `put-text-property' etc. with buffer argument calls current buffer's `after-change-functions'
From: Pip Cet <[email-masked]>
To: [email-masked]
Date: Thu, 13 Jun 2019 13:48:40 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

In emacs -Q, evaluating:

(let ((buffer1 (generate-new-buffer "A"))
      (buffer2 (generate-new-buffer "B")))
  (with-current-buffer buffer2
    (insert "BBB"))
  (with-current-buffer buffer1
    (add-hook 'after-change-functions
          (lambda (beg end len)
        (message "%S %S %S"
             beg end len))
          nil t)
    (put-text-property 1 4 'read-only t buffer2)))

results in a "1 4 3" message. I would have expected no message, as
buffer2 was modified and buffer1, whose after-change-functions I'd
set, wasn't.

I've looked at the code, and it appears no particular provisions are
being made to make sure we switch to the modified buffer before
calling signal_after_change().

As far as I can tell, this makes `put-text-property' with a buffer
argument pretty useless. Am I missing something? Is this expected
behavior somehow?