[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unbalanced change hooks (part 2) [Documentation fix still remaining]
From: |
Stefan Monnier |
Subject: |
Re: Unbalanced change hooks (part 2) [Documentation fix still remaining] |
Date: |
Wed, 10 Aug 2016 15:50:06 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
> Do @emph{not} expect the before-change hooks and the after-change
> hooks be called in balanced pairs around each buffer change. Also
> don't expect the before-change hooks to be called for every chunk of
> text Emacs is about to delete. These hooks are provided on the
> assumption that Lisp programs will use either before- or the
> after-change hooks, but not both, and the boundaries of the region
> where the changes happen might include more than just the actual
> changed text, or even lump together several changes done piecemeal.
That looks OK, thank you. It does make it sound like sometimes b-c-f
won't be called at all, whereas AFAIU it is *always* called before
a change, tho maybe "too early" (i.e. announcing several changes at the
same time), but I think it's good enough for now.
> One can (indeed, often MUST) expect b-c-f and a-c-f to work in pairs,
No. I know you *want* to expect it, but that assumption has not been
true for many years and we don't want to impose it on ourselves.
Furthermore there is no evidence that you "MUST".
I gave various examples of ways you can live with only a-c-f.
> Editing text involves deletions and insertions.
It also involves replacements.
> Deletions can be known only in before-change-functions, insertions
> only in after-change-functions.
Not at all. Deletions are definitely announced to a-c-f.
> CC Mode absolutely requires to know both deletions and insertions for
> its proper functioning. Nobody has yet demonstrated that it can work
> properly knowing only insertions, despite Stefan loudly and repeatedly
> proclaiming it can.
All major modes using syntax-propertize demonstrate it. C++ has its
share of syntactic quirks, but none that are fundamentally very
different from what we find in other languages such as Perl.
I also outlined in more detailed how to deal with a specific example you
seemed to think required absolutely to know what was there before
the deletion.
> enabling state to be determined in a before-change function and used
> in an after-change function.
That's exactly what I want to strongly discourage. Based on my
experience with CC-mode, I'd even say that it's just a bad design, even
if the hooks were always called in pairs. I don't know nor care about
how we ended up with such a design, and I understand that you might
prefer to try and live with it than to go back and rethink it, but it's
still a bad design (nor is it the only bad design we have in Emacs, of
course).
Stefan
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], (continued)
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Eli Zaretskii, 2016/08/10
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Alan Mackenzie, 2016/08/10
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Eli Zaretskii, 2016/08/10
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Alan Mackenzie, 2016/08/10
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Eli Zaretskii, 2016/08/10
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Alan Mackenzie, 2016/08/10
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Eli Zaretskii, 2016/08/10
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining],
Stefan Monnier <=
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Alan Mackenzie, 2016/08/11
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Stefan Monnier, 2016/08/11
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Daniel Colascione, 2016/08/28
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Stefan Monnier, 2016/08/28
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Daniel Colascione, 2016/08/28
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Stefan Monnier, 2016/08/28
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Daniel Colascione, 2016/08/28
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Stefan Monnier, 2016/08/28
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Daniel Colascione, 2016/08/28
- Re: Unbalanced change hooks (part 2) [Documentation fix still remaining], Stefan Monnier, 2016/08/29