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: New hook before-region-change-functions wanted Date: Sun, 10 Sep 2017 18:53:53 +0000 Message-ID: <20170910185353.GE3588@ACM> References: <20170908144657.GA3463@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1505069982 6418 195.159.176.226 (10 Sep 2017 18:59:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 10 Sep 2017 18:59:42 +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 Sun Sep 10 20:59:38 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 1dr7S5-00012a-MT for ged-emacs-devel@m.gmane.org; Sun, 10 Sep 2017 20:59:29 +0200 Original-Received: from localhost ([::1]:53966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr7SB-0005uO-FA for ged-emacs-devel@m.gmane.org; Sun, 10 Sep 2017 14:59:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr7Rc-0005uD-Dh for emacs-devel@gnu.org; Sun, 10 Sep 2017 14:59:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dr7RY-0001Hv-Ht for emacs-devel@gnu.org; Sun, 10 Sep 2017 14:59:00 -0400 Original-Received: from ocolin.muc.de ([193.149.48.4]:64033 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1dr7RY-0001H8-6D for emacs-devel@gnu.org; Sun, 10 Sep 2017 14:58:56 -0400 Original-Received: (qmail 21994 invoked by uid 3782); 10 Sep 2017 18:58:54 -0000 Original-Received: from acm.muc.de (p548C6F29.dip0.t-ipconnect.de [84.140.111.41]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 10 Sep 2017 20:58:53 +0200 Original-Received: (qmail 12975 invoked by uid 1000); 10 Sep 2017 18:53:53 -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:218093 Archived-At: Hello, Stefan. On Sat, Sep 09, 2017 at 09:44:20 -0400, Stefan Monnier wrote: > > The reason I want it is as part of the solution to bug #22983 > > (syntax-ppss returns wrong result). I envisage two (or possibly more) > > mutually independent caches, and a switch being made to the appropriate > > cache when the region is changed. This switch would be made inside a > > function on before-change-region-functions. > Regarding a hook placed on narrow-to-region (from where I stand, `widen` > is just a special call to narrow-to-region): > - As discussed in the past, narrow-to-region needs to be > extended/adjusted/complemented with some way to distinguish "hard > narrowing" (as is used in Info-mode, and might be used in cases of > multiple-major-modes) from "soft narrowing", so there's a risk such > changes would impact the desired behavior of this hook. > - syntax-ppss doesn't need this hook, and even if it were added it > probably wouldn't benefit from it: you can just as easily change > syntax-ppss to compare (point-min) with its last value in order to > detect calls to narrow-to-region. There are minor advantages to using > your hooks, but there are also similarly minor advantages to > performing the detection dynamically in syntax-ppss, and I think > overall neither approach would be noticeably better than the other. OK, first of all, I've given up the hook proposal after strong objections from Richard. `widen' is physically a separate function from `narrow-to-region'. As I see it, there is no such thing as "hard" or "soft" narrowing. There's just narrowing which is completely defined as it always has been. I'm in favour of it staying that way, having proposed alternative measures for multiple major modes. > > While it is true that this hook is not absolutely necessary, in that the > > cache switch could be made by the first call to syntax-ppss after the > > region change, it makes the cache switch clean. In particular, the > > cache will always be in synch with the region, and any functions which > > examine the cache at an arbitrary time (for example, jit-lock > > functions), will get the right cache. > AFAIK noone ever looks at syntax-ppss's cache except for syntax-ppss. > jit-lock definitely doesn't. Sorry, yes, I got a little confused. font-lock.el calls syntax-ppss, and I think I was worried that it might do so between a change in restriction and the syntax-ppss cache's getting changed. Or something like that. Nothing to worry about. Incidentally, I've now posted a patch for bug #22983. I'm interested in what you think of it. > Stefan -- Alan Mackenzie (Nuremberg, Germany).