[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lisp primitives and their calling of the change hooks
From: |
Stefan Monnier |
Subject: |
Re: Lisp primitives and their calling of the change hooks |
Date: |
Thu, 04 Jan 2018 16:36:42 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
>> which is lax enough that any behavior could be argued to be acceptable.
>> IOW I think it's too lax. We should probably try and fix it to reflect
>> the fact that every change should be covered by the last preceding b-c-f
>> and should be followed by a corresponding call to a-c-f (and this
>> before the next call to b-c-f).
> Is that quite right?
Probably not quite.
> The upcase-region call in my test had no a-c-f call, almost certainly
> because there were no lower case letters in the buffer at the time.
Indeed, there were no changes, so no need to call a-c-f.
> From your answers in this thread, I'm thinking that every
> primitive-call which could change the buffer will have exactly one
> b-c-f and zero or more a-c-f's.
Sounds about right, tho I expect some primitives might just call insert
and delete a few times, thus calling b-c-f several times.
> How about something like this to replace that paragraph from the elisp
> manual?
>
> The primitives which atomically insert or delete a contiguous chunk
> of text into or from a buffer will call `before-change-functions'
> and `after-change-functions' in balanced pairs, once for each
> change. The arguments to these hooks will exactly delimit the
> change being made. Calls to these primitives comprise the vast bulk
> of buffer changes.
>
> Other, more complex primitives aim to call `before-change-functions'
> once before making any changes, then to call
> `after-change-functions' zero, one, or several times, depending on
> how many individual changes the primitive makes. The `BEG' and
> `END' arguments to `before-change-functions' will enclose a region
> in which the individual changes are made, but won't necessarily be
> the minimal such region. The `BEG', `END', and `OLD-LEN' arguments
> to each successive call of `after-change-functions' will accurately
> delimit the current change.
Looks good to me, thank you.
I think in the case of subst-chars-in-region we only call a-c-f one time
(but with tighter bounds than those of the preceding b-c-f) rather than
once per character that's substituted, so maybe "The `BEG', `END', and
`OLD-LEN' arguments to each successive call of `after-change-functions'
will accurately delimit the current change" promises a bit more than we
deliver, although it depends on how we interpret "current change".
In any case, the above is much better than what we have now and I think
it gives a pretty good rendition of our intention.
Stefan
- Lisp primitives and their calling of the change hooks, Alan Mackenzie, 2018/01/03
- Re: Lisp primitives and their calling of the change hooks, Stefan Monnier, 2018/01/03
- Re: Lisp primitives and their calling of the change hooks, Alan Mackenzie, 2018/01/04
- Re: Lisp primitives and their calling of the change hooks, Stefan Monnier, 2018/01/04
- Re: Lisp primitives and their calling of the change hooks, Alan Mackenzie, 2018/01/04
- Re: Lisp primitives and their calling of the change hooks,
Stefan Monnier <=
- Re: Lisp primitives and their calling of the change hooks, Alan Mackenzie, 2018/01/06
- Re: Lisp primitives and their calling of the change hooks, Stefan Monnier, 2018/01/06
- Re: Lisp primitives and their calling of the change hooks, Eli Zaretskii, 2018/01/06
- Re: Lisp primitives and their calling of the change hooks, Alan Mackenzie, 2018/01/06
- Re: Lisp primitives and their calling of the change hooks, Alan Mackenzie, 2018/01/06
- Re: Lisp primitives and their calling of the change hooks, Alan Mackenzie, 2018/01/07
- Re: Lisp primitives and their calling of the change hooks, Eli Zaretskii, 2018/01/07
- Re: Lisp primitives and their calling of the change hooks, Alan Mackenzie, 2018/01/07
- Re: Lisp primitives and their calling of the change hooks, Alan Mackenzie, 2018/01/07
- [SUSPECTED SPAM] Re: Lisp primitives and their calling of the change hooks, Stefan Monnier, 2018/01/07