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: João Távora
Subject: Re: Tracking buffer positions across time, without markers (was Re: PL support)
Date: Mon, 11 May 2020 16:44:33 +0100

On Mon, May 11, 2020 at 4:33 PM Clément Pit-Claudel
<address@hidden> wrote:
>
> On 11/05/2020 11.16, João Távora wrote:
> > On Mon, May 11, 2020 at 3:18 PM Clément Pit-Claudel
> > <address@hidden> wrote:
> >
> >> Yes, eactly, that's what I meant when I wrote "Visual Studio has a nice 
> >> API for this: there is a way to snapshot a buffer, and to translate 
> >> positions between two snapshots.  In my example, this allows you to 
> >> translate 0:3 in the original buffer to 7:10 in the new one."
> >
> > Well, if I understand correctly, you can still do this with markers.
> > You just need to register, somehow, somewher, at the time you
> > make the request  to the  server that "3" means "that marker there".
> > Then recover this  information. In the worse case, this means this
> > means a table of markers that is as the number of positions in the
> > buffer, which is probably a performance no-no :-(
>
> Indeed :(

Of course, the smart way is to use the buffer-undo-list.  Now I
understand Stefan's suggestion. You should be able to record
the value of the variable buffer-undo-list into a variable
at the time you make the request.  Then you need a function
that, given that value OLD-BUL, a buffer position OLD, the new
value of buffer-undo-list NEW-BUL and a thing called X,  gives
you the current buffer position NEW where a marker of type X would
have ended up if it had been set at OLD. This is a nice elisp exercise,
good for unit-testing with ert.  If you post it to emacs-help or reddit
someone maybe someone will do the hard work for you (maybe
a change from the general theme of indignation).

João



reply via email to

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