From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Bug #25608 and the comment-cache branch Date: Sat, 18 Feb 2017 10:44:38 +0000 Message-ID: <20170218104437.GA2503@acm> References: <20170203172952.GC2250@acm> <0a40d539-b7bc-2655-5429-6280022106ee@yandex.ru> <20170204102410.GA2047@acm> <8f9e68fc-4314-625d-b4bf-796c71c91798@yandex.ru> <20170206192423.GB3568@acm> <4f0fabf3-be9c-7492-379b-59dc93e72b4f@yandex.ru> <20170207192119.GA2490@acm> <424e6409-029c-d15d-421c-4fb90594329c@yandex.ru> <20170214211423.GA3090@acm> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1487414750 6506 195.159.176.226 (18 Feb 2017 10:45:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Feb 2017 10:45:50 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 18 11:45:46 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cf2WO-0000zJ-1X for ged-emacs-devel@m.gmane.org; Sat, 18 Feb 2017 11:45:44 +0100 Original-Received: from localhost ([::1]:57995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cf2WT-000114-NY for ged-emacs-devel@m.gmane.org; Sat, 18 Feb 2017 05:45:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cf2Vq-0000x1-H7 for emacs-devel@gnu.org; Sat, 18 Feb 2017 05:45:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cf2Vl-0007SA-KC for emacs-devel@gnu.org; Sat, 18 Feb 2017 05:45:10 -0500 Original-Received: from ocolin.muc.de ([193.149.48.4]:62354 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1cf2Vl-0007PX-8c for emacs-devel@gnu.org; Sat, 18 Feb 2017 05:45:05 -0500 Original-Received: (qmail 16628 invoked by uid 3782); 18 Feb 2017 10:45:01 -0000 Original-Received: from acm.muc.de (p4FC46853.dip0.t-ipconnect.de [79.196.104.83]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 18 Feb 2017 11:45:00 +0100 Original-Received: (qmail 3564 invoked by uid 1000); 18 Feb 2017 10:44:38 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:212443 Archived-At: Hello, Stefan. On Thu, Feb 16, 2017 at 09:10:44 -0500, Stefan Monnier wrote: > > It was a case of seeing if two distinct syntax tables were "the same" > > from the point of view of literals. In other words, they could parse > > parentheses, whitespace and so on however they liked, but comments and > > strings had to be parsed identically by both tables for them to count > > "the same". > Interesting. Indeed, given that syntax-ppss has to pay attention to > more than comments and strings, equivalence between syntax-tables is > never something I considered. For syntax-ppss, two syntax tables are either `equal' or not. There's probably no other useful standard of equivalence here. > > This is an instance where syntax-ppss's ambitions count against it - on > > any set-syntax-table syntax-ppss's caches should really be cleared, > > strictly speaking. > As you know, syntax-ppss's caching is fairly naive currently and doesn't > make enough checks to give correct results in some cases. Changes in > the syntax-tables and in point-min being two examples discussed here. Another example is modify-syntax-entry, though this is surely less important, since it will almost always be done at initialisation only. Zapping the syntax-ppss cache is probably a good way of handling it. > I already suggested to fix the issue w.r.t point-min by replacing > syntax-ppss-cache with a table indexed by the value of point-min. > The same idea could be used for syntax-tables. I.e. make > syntax-ppss-cache indexed by the combination of syntax-table and > point-min. We'd need to be careful not to fill up too much RAM with these caches, particularly for different values of point-min. > Another option is to provide a `with-temp-syntactic-context` macro, > which would locally bind syntax-ppss-cache to nil. So code which needs > to temporarily use a different point-min and/or syntax-table for some > parsing&navigation work could use this macro to avoid being affected by > the normal cache as well as polluting the cache. I'm not too keen on the "using a different point-min for some parsing" bit. I suggest, again, using island-start and island-end syntactic markers (these optionally supply a different syntax table). These would enable things like temporarily "narrowing to (what looks like) a comment" and permanently marking a region as an island (e.g. for multiple major modes), yet the syntax at any position would be rigorous and unique throughout the buffer. > I use this approach of let-binding syntax-ppss-cache in sm-c-mode, for > example (and yes: it's a dirty hack since sm-c-mode shouldn't mess with > syntax-ppss's internals). > Which approach is best depends on the use: If that same syntax-table > will be reused many times (so caching between uses would be beneficial), > then indexing by syntax-table in syntax-ppss-cache is likely the better > choice, otherwise with-temp-syntactic-context is probably all you need. > Stefan -- Alan Mackenzie (Nuremberg, Germany).