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: An idea: combine-change-calls Date: Sat, 24 Mar 2018 18:18:05 -0400 Message-ID: References: <20180324135024.GA6319@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1521939060 19066 195.159.176.226 (25 Mar 2018 00:51:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 25 Mar 2018 00:51:00 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 25 01:50:56 2018 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 1ezts7-0004qw-KV for ged-emacs-devel@m.gmane.org; Sun, 25 Mar 2018 01:50:55 +0100 Original-Received: from localhost ([::1]:49595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eztuB-0006rq-2J for ged-emacs-devel@m.gmane.org; Sat, 24 Mar 2018 20:53:03 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ezttF-0006pX-HW for emacs-devel@gnu.org; Sat, 24 Mar 2018 20:52:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eztt2-0003uX-A9 for emacs-devel@gnu.org; Sat, 24 Mar 2018 20:52:05 -0400 Original-Received: from [195.159.176.226] (port=50354 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ezrUO-0007FN-76 for emacs-devel@gnu.org; Sat, 24 Mar 2018 18:18:16 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ezrSH-0005tp-Sd for emacs-devel@gnu.org; Sat, 24 Mar 2018 23:16:05 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:VM8X14mGUh0JI+1X1E+P69IXHHY= 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:223988 Archived-At: > The motivation is bug #30735, [ Not surprised: I told you CC-mode's change-functions are too costly, because they presumes that before&after-change-functions are called at a "human" rate (comparable to pre/post-command-hook). before&after-change-functions should be handled a bit like POSIX signals: do as little work as possible there, and handle them later elsewhere. `comment-region` is not the only command that can make many small changes. ] > What do people think? I actually do like the idea of combining such things, tho it's risky: e.g. if the code within combine-change-calls uses syntax-ppss it might get wrong results since syntax-ppss-flush-cache is triggered via before-change-functions. The same problem would affect syntax-propertize, of course. Grepping for `add-hook.*before-change-functions` indicates that similar problem could appear elsewhere. Not sure what to do about it other than to say "don't over-use it, it might bite you". Also we'd need such a system to check that the bounds are indeed obeyed. One more thing: with the sample code you showed, undoing will still be just as slow since it won't benefit from combine-change-calls. Maybe combine-change-calls should also combine all those changes on the undo-list into a big "delete+insert" (of course, it could also try and keep the undo granularity but mark those undo entries so that they're undone within their own combine-change-calls). Stefan