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

From: Eli Zaretskii <[email-masked]>
Date: Thu, 13 Jun 2019 22:05:48 +0300

> From: Pip Cet <[email-masked]>
> Date: Thu, 13 Jun 2019 18:48:23 +0000
> Cc: [email-masked]
> 
> > > As far as I can tell, this makes `put-text-property' with a buffer
> > > argument pretty useless.
> >
> > Only if you have a buffer-local value of after-change-functions.
> 
> I'm not sure what you're saying.

I'm saying that the buffer argument to put-text-property is pretty
useless only if you consider after-change-functions.  The primary
purpose of put-text-property is to modify text properties, not to call
after-change-functions.  For that primary purpose, the buffer argument
is not useless.

> That seems pretty wrong to me. In which cases do you think we're
> seeing the right behavior?

Where did I say that this behavior was right?

> Here's a first patch, which adds a "buffer" argument to
> signal_after_change, to be explicit about where the change happens. It
> should be pretty cheap in the case where we don't switch buffers.

Not sure I have a clear idea of how you intend to use that additional
argument.  Are you suggesting that we switch to that buffer?  If so,
how is that different from not using the buffer argument at all, and
instead wrapping the call to put-text-property with
with-current-buffer?

Also, passing current_buffer sounds redundant to me anyway, because in
that case signal_after_change will not need to do anything that it
doesn't already do.  I would pass NULL instead.

Thanks.