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]>
Date: Fri, 14 Jun 2019 10:41:45 +0300

> From: Pip Cet <[email-masked]>
> Date: Thu, 13 Jun 2019 21:37:40 +0000
> Cc: [email-masked]
> 
> +/* Signal a change immediately after it happens.
> +   BUFFER is the buffer in which the change happened.
> +   CHARPOS is the character position of the start of the changed text.
> +   LENDEL is the number of characters of the text before the change.
> +   (Not the whole buffer; just the part that was changed.)
> +   LENINS is the number of characters in that part of the text
> +   after the change.  */

I would just say "Like signal_after_change, but ..." and describe only
the BUFFER argument.

> +void
> +signal_after_change_in_buffer (struct buffer *buffer, ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins)
> +{
> +  ptrdiff_t count = SPECPDL_INDEX ();
> +
> +  record_unwind_current_buffer ();
> +  set_buffer_internal (buffer);
> +  signal_after_change (charpos, lendel, lenins);
> +  unbind_to (count, Qnil);
> +}

I still think we should explicitly detect the current_buffer case here
and if so, avoid the calls to everything else except
signal_after_change itself.

But I indeed like this patch better, although the concerns over the
performance hit are still present.  Thanks.