On Fri, Jun 14, 2019 at 7:41 AM Eli Zaretskii wrote: > > > From: Pip Cet > > Date: Thu, 13 Jun 2019 21:37:40 +0000 > > Cc: 36190@debbugs.gnu.org > > > > +/* 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. Okay, I fixed those two issues. As for the performance problem, should we amend the documentation to state that if many changes are made, it's better to use `with-current-buffer' instead of repeatedly calling put-text-property with a buffer argument?