From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Bug #25608 and the comment-cache branch Date: Thu, 16 Feb 2017 09:10:44 -0500 Message-ID: References: <20170202215154.GB2505@acm> <83h94bvhzw.fsf@gnu.org> <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 X-Trace: blaine.gmane.org 1487256762 6799 195.159.176.226 (16 Feb 2017 14:52:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 16 Feb 2017 14:52:42 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 16 15:52:36 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 1ceNPD-0007HI-Lu for ged-emacs-devel@m.gmane.org; Thu, 16 Feb 2017 15:51:35 +0100 Original-Received: from localhost ([::1]:47071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNFv-0002ze-88 for ged-emacs-devel@m.gmane.org; Thu, 16 Feb 2017 09:41:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceMly-0006ly-Ro for emacs-devel@gnu.org; Thu, 16 Feb 2017 09:11:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceMlu-0006NH-RD for emacs-devel@gnu.org; Thu, 16 Feb 2017 09:11:02 -0500 Original-Received: from [195.159.176.226] (port=34751 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceMlu-0006MZ-Je for emacs-devel@gnu.org; Thu, 16 Feb 2017 09:10:58 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ceMlg-00019C-Jf for emacs-devel@gnu.org; Thu, 16 Feb 2017 15:10:44 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 41 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:Gm2rjESPxufiq7sk6fT7fxiwrUE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:212423 Archived-At: > 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. > 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. 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. 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 use this approach of let-binding syntax-ppss-cache is 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