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: Sun, 9 Jun 2019 14:52:23 +0000 Message-ID: <20190609145223.GA6712@ACM> References: <20190608131724.GA4643@ACM> <20190608203639.GA28722@ACM> <83ef43cndu.fsf@gnu.org> 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="26089"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 36136@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 09 16:53:29 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 1hZzCK-0006cs-1w for geb-bug-gnu-emacs@m.gmane.org; Sun, 09 Jun 2019 16:53:28 +0200 Original-Received: from localhost ([::1]:36214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZzCI-0005lD-E4 for geb-bug-gnu-emacs@m.gmane.org; Sun, 09 Jun 2019 10:53:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34008) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZzBv-0005l7-SR for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2019 10:53:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZzBu-0000MP-QD for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2019 10:53:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZzBu-0000MH-Mo for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2019 10:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hZzBu-0000o4-If for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2019 10:53: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: Sun, 09 Jun 2019 14:53: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.15600919533065 (code B ref 36136); Sun, 09 Jun 2019 14:53:02 +0000 Original-Received: (at 36136) by debbugs.gnu.org; 9 Jun 2019 14:52:33 +0000 Original-Received: from localhost ([127.0.0.1]:55187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hZzBQ-0000nN-Su for submit@debbugs.gnu.org; Sun, 09 Jun 2019 10:52:33 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:31462 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hZzBO-0000nD-8s for 36136@debbugs.gnu.org; Sun, 09 Jun 2019 10:52:30 -0400 Original-Received: (qmail 99018 invoked by uid 3782); 9 Jun 2019 14:52:24 -0000 Original-Received: from acm.muc.de (p2E5D56FA.dip0.t-ipconnect.de [46.93.86.250]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 09 Jun 2019 16:52:23 +0200 Original-Received: (qmail 8897 invoked by uid 1000); 9 Jun 2019 14:52:23 -0000 Content-Disposition: inline In-Reply-To: <83ef43cndu.fsf@gnu.org> 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:160284 Archived-At: Hello, Eli. Thanks for criticising my proposed patch. On Sun, Jun 09, 2019 at 08:56:45 +0300, Eli Zaretskii wrote: > > Date: Sat, 8 Jun 2019 20:36:39 +0000 > > From: Alan Mackenzie > > > Suggested fix: the functions set_properties, add_properties, > > > remove_properties in textprop.c should check for changes to, > > > specifically, syntax-table properties. When these changes are detected, > > > a hook called something like syntax-table-props-change-alert-hook should > > > be called (with some appropriate position parameters, tbd). > > > syntax-ppss-flush-cache will be added to this hook. > > Here is a first draught of a fix to this bug. > I have no opinion about the issue and the idea of its proposed > solution, but I do have some comments to the implementation. [ .... ] > This means that whenever syntax.el is loaded (i.e., always, since > syntax.el is preloaded), this hook will be non-nil. Is that a good > idea? I mean, if we always call this function, why do this via a > hook? No, it's not a good idea. Mainly because of .... [ .... ] > Also, what about the safety of this call? what if the hook signals an > error or the user presses C-g while the hook runs? IOW, should you > use safe_call or some of its variants, and should you inhibit QUIT? > and if so, whether and how should you handle in the code the case when > the hook does signal an error? .... add-text-properties and friends are called from redisplay. So it would be particularly inconvenient for a hook function to throw an error here - some sophisticated error handling (like there must be for fontification-functions) would be needed. You're right. All that the hook function really needs to do is set some buffer local syntax-ppss variable indicating the maximum valid position. This doesn't need a hook, just a new variable in syntax.c and code there and in syntax-ppss to use it. [ All other comments noted, and to a large extent incorporated into the code.] So, I'll start again. Thanks! -- Alan Mackenzie (Nuremberg, Germany).