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: Sun, 10 May 2020 00:26:09 +0100

On Sat, May 9, 2020 at 11:22 PM Clément Pit-Claudel
<address@hidden> wrote:
>
> On 09/05/2020 17.38, João Távora wrote:
> > On Sat, May 9, 2020 at 8:47 PM Clément Pit-Claudel <address@hidden 
> > <mailto:address@hidden>> wrote:
> >
> >     Can you clarify what you mean by 'a solved problem'?
> >
> >
> > I meant it in the context of LSP.
> >
> >
> >     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!
> >
> >
> > Some idle time after you type, Eglot will inform the LSP server
> > that things have changed, and it will reply with more stuff
> > to highlight.
> >
> > This is how I interpret this.  It's the way it works with, say syntax
> > errors, which are already supported.  I've NOT looked at the spec.
> >
> > Did this help?
>
> A bit.  But this works only if the interaction is fast enough, right? (Same 
> for syntax errors: positions may well be outdated by the time the errors come 
> back)

By that time another request is probably already underway.
The same thing happens in completion, for example.  As you
type more characters, the completion list that is about to be
rendered loses validity, you have to request another one.

This is done with an idle timer, much the way that Flycheck
works, I believe.  So you're not emitting one request per
keystroke. You emit a "check this buffer" request once the
user has stopped changing the buffer for a little while.

For syntax highlighting, and indentation, I suppose you would
want to do it every n inputs too, so that typing really fast doesn't
break too much.

But, as I said, I haven't read any of the spec yet on this topic,
because it is very new.

João



reply via email to

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