emacs-devel
[Top][All Lists]
Advanced

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

Idea for syntax-ppss. Is it new? Could it be any good?


From: Alan Mackenzie
Subject: Idea for syntax-ppss. Is it new? Could it be any good?
Date: Sat, 26 Jul 2008 21:44:29 +0000
User-agent: Mutt/1.5.9i

Hi, Emacs,

Looking at the doc string for syntax-ppss, it seems this could be _very_
useful in a certain body of code I'm responsible for.  That body of code
has a lot of heuristics that determine whether point is within a
string/comment, and some of these are not watertight (such as hard-coded
limits on comment sizes to achieve speed).  Basically, they're a PITA.
syntax-ppss, if it was guaranteed watertight, could remove the gnawing
uncertainty from much of the code.

However, the manual documents limitations on syntax-ppss's functionality.

How about reimplementing it thusly?:  The current syntax would be cached
for positions at every N bytes (where N would be, perhaps 1024, possibly
8192).  A call to syntax-ppss would simply call parse-partial-sexp from
the latest valid cached position, filling out the cache as it goes.  Any
buffer change would invalidate cached values for N > POS.

I envisage coding this in C rather than Lisp.  There would be some
complications to do with making sure the syntax table isn't tampered
with, and so on.  This code would surely be fast and reliable.

Obviously I'm not proposing this for the pending release, but what do
people think about the idea?

-- 
Alan Mackenzie (Nuremberg, Germany)




reply via email to

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