From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#36136: [PATCH]: Re: bug#36136: syntax-ppss fails to invalidate its cache on changes to syntax-table text properties Date: Wed, 12 Jun 2019 10:15:03 +0000 Message-ID: <20190612101503.GA4587@ACM> References: <20190608131724.GA4643@ACM> <20190609183912.GA17965@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="186645"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 36136@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 12 12:22:24 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hb0Od-000mR3-PA for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Jun 2019 12:22:23 +0200 Original-Received: from localhost ([::1]:58418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0Oc-0003HM-Mk for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Jun 2019 06:22:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51397) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0IW-0000TX-D2 for bug-gnu-emacs@gnu.org; Wed, 12 Jun 2019 06:16:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb0IV-0000QB-0J for bug-gnu-emacs@gnu.org; Wed, 12 Jun 2019 06:16:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hb0IU-0000Q3-M9 for bug-gnu-emacs@gnu.org; Wed, 12 Jun 2019 06:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hb0IU-0005pG-F6 for bug-gnu-emacs@gnu.org; Wed, 12 Jun 2019 06:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Jun 2019 10:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36136 X-GNU-PR-Package: emacs Original-Received: via spool by 36136-submit@debbugs.gnu.org id=B36136.156033451122283 (code B ref 36136); Wed, 12 Jun 2019 10:16:02 +0000 Original-Received: (at 36136) by debbugs.gnu.org; 12 Jun 2019 10:15:11 +0000 Original-Received: from localhost ([127.0.0.1]:60750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hb0Hf-0005nL-5B for submit@debbugs.gnu.org; Wed, 12 Jun 2019 06:15:11 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:44286 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hb0Hd-0005nA-Fj for 36136@debbugs.gnu.org; Wed, 12 Jun 2019 06:15:10 -0400 Original-Received: (qmail 85848 invoked by uid 3782); 12 Jun 2019 10:15:05 -0000 Original-Received: from acm.muc.de (p4FE15E42.dip0.t-ipconnect.de [79.225.94.66]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 12 Jun 2019 12:15:03 +0200 Original-Received: (qmail 5847 invoked by uid 1000); 12 Jun 2019 10:15:03 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:160425 Archived-At: Hello, Stefan. On Wed, Jun 12, 2019 at 04:37:25 -0400, Stefan Monnier wrote: > > The following patch is simpler than my first proposal, following > > feedback from Eli. It works for me. > > Stefan, could you look at this, please? > Here I am. Hello! > > * src/textprop.c (syntax-propertize--done): New buffer local variable. > > (set_properties, add_properties, remove_properties): when a syntax-table text > > property is being changed, reduce syntax-propertize--done to the buffer > > position. > Hmm... I'm not too fond of adding ad-hoc support for specific > text-properties in (set_properties, add_properties, remove_properties). Neither am I, particularly. But the whole point of syntax-ppss, surely, is that it should work automatically, without users having to call syntax-ppss-flush-cache all the time. The root of the problem is that inhibit-modification-hooks is too blunt a tool. Setting it prevents running functions we want to run, just as much as ones we don't. I've just had another idea: we introduce a new property called something like dont-inhibit. When a function in before/after-change-functions has this property, it would run, regardless of inhibit-modification-hooks. Or possibly, we could introduce new hooks no-inhibit-before/after-change-functions. What do you think? > > * lisp/emacs-lisp/syntax.el (syntax-ppss--trim-cache): New function extracted > > from syntax-ppss-flush-cache. > > (syntax-ppss-flush-cache): Now only modifies syntax-propertize--done and > > syntax-ppss--done. > > (syntax-ppss): Calls syntax-ppss--trim-cache and sets syntax-propertize--done. > This part looks OK. > I'm not sure if making the cache-flushing more lazy will be a win > overall: it speeds up buffer modifications at the cost of slowing down > syntax-ppss. It will probably not make a great deal of difference either way. Buffer changes are frequent in Emacs, and so are calls to syntax-ppss in many major modes. > To get back to the original problem: > > This is because the invalidation function, syntax-ppss-flush-cache is > > invoked only as a before-change function, but typical (?all) > > syntax-table property changes happen when before-change-functions > > is inactive. > That's why it doesn't have "--" in its name: if you don't want to use > syntax-propertize then you'll probably have to call that function > by hand. I consider it as perfectly acceptable. Well, for CC Mode I'm going to have to do that anyway, since Emacs-26.x and earlier are already out there and aren't going to change. This is going to be tedious and error prone. But for the future, it would be nice if syntax-ppss could take note of all buffer changes, rather than just some of them. > Stefan -- Alan Mackenzie (Nuremberg, Germany).