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: New hook before-region-change-functions wanted Date: Fri, 8 Sep 2017 14:46:57 +0000 Message-ID: <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 1504882511 16269 195.159.176.226 (8 Sep 2017 14:55:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 8 Sep 2017 14:55:11 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 08 16:55:07 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 1dqKgP-0003eH-Nc for ged-emacs-devel@m.gmane.org; Fri, 08 Sep 2017 16:55:01 +0200 Original-Received: from localhost ([::1]:45829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqKgT-0006pa-Pr for ged-emacs-devel@m.gmane.org; Fri, 08 Sep 2017 10:55:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqKdM-0004hI-07 for emacs-devel@gnu.org; Fri, 08 Sep 2017 10:51:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqKdH-0008O5-24 for emacs-devel@gnu.org; Fri, 08 Sep 2017 10:51:52 -0400 Original-Received: from ocolin.muc.de ([193.149.48.4]:64362 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1dqKdG-0008L5-Mx for emacs-devel@gnu.org; Fri, 08 Sep 2017 10:51:46 -0400 Original-Received: (qmail 92912 invoked by uid 3782); 8 Sep 2017 14:51:45 -0000 Original-Received: from acm.muc.de (p548C791B.dip0.t-ipconnect.de [84.140.121.27]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 08 Sep 2017 16:51:44 +0200 Original-Received: (qmail 3495 invoked by uid 1000); 8 Sep 2017 14:46:57 -0000 Content-Disposition: inline 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:218018 Archived-At: Hello, Emacs. I would like to implement a new abnormal hook, before-change-region-functions. It would be called just before a change in the buffer's restriction (i.e., from widen and from narrow-to-region) and each function on it would take two parameters, the beginning and end of the new region being set. 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. 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. The mechanism will also work a little faster with the new hook than without it, given that changes of restriction are more rarely effected than syntax-ppss is called. -- Alan Mackenzie (Nuremberg, Germany).