emacs-devel
[Top][All Lists]
Advanced

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

Re: Tracking buffer positions across time, without markers (was Re: PL s


From: Stefan Monnier
Subject: Re: Tracking buffer positions across time, without markers (was Re: PL support)
Date: Sun, 10 May 2020 16:46:29 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> The general problem is this: I send the contents of a buffer to
> a subprocess.  Some time later, the subprocess returns a list of positions
> (offsets from the beginning of the buffer, or line/column pairs, etc).
> At that point, these positions may be stale, since the contents of the
> buffer may have changed.  I need a way to translate these positions
> (relative to the old buffer contents) into positions relative to the new
> buffer contents.

As you said you should be able to use the undo-list for that.
It'll require a bit of work, but hopefully that can be used in
several places, justifying the investment.

If you have the option to ask for a more up-to-date version of the data
to be sent, you can obviously throw the data away, but even in that case
you should be able to do better with fairly little work: use an
after-change-function to keep track of just 2 markers that indicate the
beginning and end of the part of the buffer that's been modified.
Then you can easily translate all the positions before the first and
after the second marker and only discard the data between the two.


        Stefan




reply via email to

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