From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: "Emacs developers" <emacs-devel@gnu.org>,
"João Távora" <joaotavora@gmail.com>
Subject: Tracking buffer positions across time, without markers (was Re: PL support)
Date: Sat, 9 May 2020 15:47:33 -0400 [thread overview]
Message-ID: <6a2c7d18-344e-fefb-63d5-79a99d0532fc@gmail.com> (raw)
Hi João,
On 09/05/2020 13.08, João Távora wrote:
> Since exchanging information about source-file changes is largely a
> solved problem, as soon as servers start declaring support the new
> syntax highlighting extensions, it's is a question of applying the
> text properties in an efficient manner.
Can you clarify what you mean by 'a solved problem'? One long-standing issue that I've had with Emacs is that I don't know of a way to track buffer positions without adding markers. Here's a concrete example:
I start with a buffer that contains "int foo ()", and send that to a subprocess (say a syntax highlighter, for example). It returns [0:3:type; 4:7:name]. In the meantime, the user has inserted more text in the buffer, which now contains "static int foo ()". If I apply the highlighting as-is, it will be all wrong!
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.
I don't think Emacs has such a facility at the moment — did I miss something?
I've been thinking of building one for a while. I think it can be done entirely in ELisp, by using the undo list: snapshots would be pointers into the undo list, and positions could be translated by iterating over all undo list entries between two snapshots and adjusting positions according to each undo-list entry.
Are you using something different in eglot? Or are you assuming that calls are fast enough that this isn't a problem? I ran into this problem with very slow subprocesses, like running an SMT solver.
Clément.
next reply other threads:[~2020-05-09 19:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-09 19:47 Clément Pit-Claudel [this message]
2020-05-09 21:38 ` Tracking buffer positions across time, without markers (was Re: PL support) João Távora
2020-05-09 22:22 ` Clément Pit-Claudel
2020-05-09 23:26 ` João Távora
2020-05-10 3:45 ` Clément Pit-Claudel
2020-05-10 4:32 ` Eli Zaretskii
2020-05-10 19:27 ` Clément Pit-Claudel
2020-05-10 19:42 ` Drew Adams
2020-05-10 19:49 ` Eli Zaretskii
2020-05-10 20:52 ` Clément Pit-Claudel
2020-05-11 14:24 ` Eli Zaretskii
2020-05-11 15:03 ` Clément Pit-Claudel
2020-05-11 15:25 ` Stefan Monnier
2020-05-10 20:46 ` Stefan Monnier
2020-05-11 2:27 ` Eli Zaretskii
2020-05-11 3:19 ` Stefan Monnier
2020-05-11 0:17 ` Vladimir Sedach
2020-05-11 14:18 ` Clément Pit-Claudel
2020-05-11 15:16 ` João Távora
2020-05-11 15:33 ` Clément Pit-Claudel
2020-05-11 15:44 ` João Távora
2020-05-11 16:02 ` Clément Pit-Claudel
2020-05-11 16:11 ` João Távora
2020-05-11 17:20 ` Stefan Monnier
2020-05-11 14:39 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a2c7d18-344e-fefb-63d5-79a99d0532fc@gmail.com \
--to=cpitclaudel@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=joaotavora@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.