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

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> gmail.com>

Date: Thu, 13 Jun 2019 13:50:02 UTC

Severity: normal

Found in version 27.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #38 received at 36190 <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 36190 <at> debbugs.gnu.org
Subject: Re: bug#36190: 27.0.50; `put-text-property' etc. with buffer argument
 calls current buffer's `after-change-functions'
Date: Fri, 14 Jun 2019 11:14:53 +0000
[Message part 1 (text/plain, inline)]
On Fri, Jun 14, 2019 at 7:41 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: Pip Cet <pipcet <at> gmail.com>
> > Date: Thu, 13 Jun 2019 21:37:40 +0000
> > Cc: 36190 <at> 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?
[0001-Switch-to-correct-buffer-in-put-text-property-etc.patch (text/x-patch, attachment)]

This bug report was last modified 6 years and 17 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.