emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unbalanced change hooks (part 2)


From: Stefan Monnier
Subject: Re: Unbalanced change hooks (part 2)
Date: Tue, 02 Aug 2016 10:46:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> Slightly less gross, perhaps:
> (i) Abandon the use of before-change-functions.
> (ii) Enable undo in pre-command-hook, if necessary.
> (iii) At each after-change-functions call:
>   a - Analyze buffer-undo-list down as far as (or pos (next-nil)), and
>     revert the insertion or deletion which as been made, taking
>     particular care over coalesced multiple insertions/deletions.
>   b - (setq pos (current-position-in-undo-list))
>   c - Perform what used to be before-change actions.
>   d - restore the insertion/deletion.
>   e - Perform the normal after-change functions.
> (iv) Disable undo in post-command-hook, if appropriate.

Alan.  I urge you to take a step back and think about how to solve your
problem without looking at the details of each change.

I am 100% sure, based on my experience with lots of major modes
(including cc-mode), that the result will be more robust, simpler, and
at least as efficient.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]