[Top][All Lists]

[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: Drew Adams
Subject: RE: Tracking buffer positions across time, without markers (was Re: PL support)
Date: Sun, 10 May 2020 12:42:04 -0700 (PDT)

> > Can you explain why using markers is not a good solution for this?
> Of course: in brief, because we don't know where to put the markers.
> 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.
> Since we don't know beforehand what positions the subprocess will
> return, I don't think markers can help; right?

The closest example I can recall, of handling this
kind of thing, is what is done for bookmarks.

In that case, in addition to saving the position,
some buffer text surrounding the position is saved,
as context.  In the case of bookmarks, saving can
be, and often is, persistent. 

Later (in the case of bookmarks, maybe MUCH later),
when the bookmark is jumped to, the code first goes
to the recorded position.  It then looks ahead and
back for context matches.  If necessary and possible,
it relocates the position based on the updated
content and matching context.

It can also prompt the user to confirm relocating
to the newly found position.

Dunno if such an approach is feasible/helpful in
the case you're considering.

reply via email to

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