From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Idea for syntax-ppss. Is it new? Could it be any good? Date: Sat, 26 Jul 2008 21:44:29 +0000 Message-ID: <20080726214429.GB3623@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1217108684 18465 80.91.229.12 (26 Jul 2008 21:44:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 26 Jul 2008 21:44:44 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 26 23:45:34 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KMrZy-0003Vr-M2 for ged-emacs-devel@m.gmane.org; Sat, 26 Jul 2008 23:45:31 +0200 Original-Received: from localhost ([127.0.0.1]:36274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KMrZ4-0001jR-L1 for ged-emacs-devel@m.gmane.org; Sat, 26 Jul 2008 17:44:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KMrYz-0001iX-1N for emacs-devel@gnu.org; Sat, 26 Jul 2008 17:44:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KMrYy-0001hs-6C for emacs-devel@gnu.org; Sat, 26 Jul 2008 17:44:28 -0400 Original-Received: from [199.232.76.173] (port=56429 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KMrYx-0001hc-TR for emacs-devel@gnu.org; Sat, 26 Jul 2008 17:44:28 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:3777 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KMrYw-0004Rw-Uq for emacs-devel@gnu.org; Sat, 26 Jul 2008 17:44:27 -0400 Original-Received: (qmail 80985 invoked by uid 3782); 26 Jul 2008 21:44:18 -0000 Original-Received: from acm.muc.de (pD9E51774.dip.t-dialin.net [217.229.23.116]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Sat, 26 Jul 2008 23:44:16 +0200 Original-Received: (qmail 4510 invoked by uid 1000); 26 Jul 2008 21:44:29 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:101567 Archived-At: 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)