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: New hook before-region-change-functions wanted Date: Sat, 09 Sep 2017 09:44:20 -0400 Message-ID: References: <20170908144657.GA3463@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1504964766 7627 195.159.176.226 (9 Sep 2017 13:46:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 9 Sep 2017 13:46:06 +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 Sat Sep 09 15:46:00 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 1dqg51-0001Ih-IY for ged-emacs-devel@m.gmane.org; Sat, 09 Sep 2017 15:45:51 +0200 Original-Received: from localhost ([::1]:49537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqg58-0004Fs-LQ for ged-emacs-devel@m.gmane.org; Sat, 09 Sep 2017 09:45:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqg4X-0004FY-LR for emacs-devel@gnu.org; Sat, 09 Sep 2017 09:45:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqg4S-0008LI-Q5 for emacs-devel@gnu.org; Sat, 09 Sep 2017 09:45:21 -0400 Original-Received: from [195.159.176.226] (port=40803 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dqg4S-0008Kb-Jl for emacs-devel@gnu.org; Sat, 09 Sep 2017 09:45:16 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dqg3k-00060C-31 for emacs-devel@gnu.org; Sat, 09 Sep 2017 15:44:32 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 33 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:sVVfWL0Hoee4cYfqMlnMUv77fUo= 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:218064 Archived-At: > 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. > 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. Stefan