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: Unbalanced change hooks (part 2) [Documentation fix still remaining] Date: Tue, 30 Aug 2016 18:16:38 +0000 Message-ID: <20160830181637.GD6672@acm.fritz.box> References: <7e1478b6-cf00-fcbf-8c24-43bdaa57e2b6@dancol.org> <415d1cca-f32c-624e-a4be-9aadcf8a0f17@dancol.org> <83inujbpek.fsf@gnu.org> <20160830171222.GA6672@acm.fritz.box> <83inuimajv.fsf@gnu.org> <20160830174223.GB6672@acm.fritz.box> <83d1kqm9cj.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1472581079 31158 195.159.176.226 (30 Aug 2016 18:17:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Aug 2016 18:17:59 +0000 (UTC) User-Agent: Mutt/1.5.24 (2015-08-30) Cc: dancol@dancol.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 30 20:17:55 2016 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 1benbb-0007Ca-Fl for ged-emacs-devel@m.gmane.org; Tue, 30 Aug 2016 20:17:51 +0200 Original-Received: from localhost ([::1]:50634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1benbZ-0007tW-3w for ged-emacs-devel@m.gmane.org; Tue, 30 Aug 2016 14:17:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1benaw-0007tK-Sz for emacs-devel@gnu.org; Tue, 30 Aug 2016 14:17:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1benar-0005JL-Qj for emacs-devel@gnu.org; Tue, 30 Aug 2016 14:17:10 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:24888) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1benar-0005Im-Hd for emacs-devel@gnu.org; Tue, 30 Aug 2016 14:17:05 -0400 Original-Received: (qmail 31992 invoked by uid 3782); 30 Aug 2016 18:17:03 -0000 Original-Received: from acm.muc.de (p548C605C.dip0.t-ipconnect.de [84.140.96.92]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 30 Aug 2016 20:17:02 +0200 Original-Received: (qmail 7102 invoked by uid 1000); 30 Aug 2016 18:16:38 -0000 Content-Disposition: inline In-Reply-To: <83d1kqm9cj.fsf@gnu.org> 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 X-Received-From: 193.149.48.3 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:206989 Archived-At: Hello, Eli. On Tue, Aug 30, 2016 at 08:53:48PM +0300, Eli Zaretskii wrote: > > Date: Tue, 30 Aug 2016 17:42:24 +0000 > > Cc: dancol@dancol.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org > > From: Alan Mackenzie > > > Your attempt didn't describe the current implementation. It described > > > what you thought it should be. > > The text in question (intended for the Elisp manual) was: > > Normally the before-change-functions and the after-change-functions > > hooks are called in balanced pairs around each buffer change, enabling > > state to be determined in a before-change function and used in an > > after-change function. However on rare occasions, > > before-change-functions is not called before a buffer change and > > after-change-functions is thus called twice in succession. Your > > program should be ready to deal with such an occurrence. > > The crucial part of that is the first sentence. It is true. > We use "normally" in the manual to mean "always, unless changed by > customizations". So the above use of that word is extremely confusing > and thus a bad idea. The before-change-functions and after-change-functions hooks are almost always called in balanced pairs around each buffer change, enabling state to be determined in a before-change-function and used in an after-change-function. However, on rare occasions, .... > And the part about "balanced pairs" is simply false, if "balanced" is > to be interpreted in its everyday's meaning. I don't understand what you mean. By balanced, I essentially mean that (i) b-c-f and a-c-f alternate, (ii) b-c-f's beg is the same as a-c-f's beg, (iii) b-c-f's (- end beg) is equal to a-c-f's old-len. In that sense b/a-c-f are balanced in the overwhelming majority of cases. > > The second sentence is true in essence, though it possibly needs to be > > made more accurate to deal with other cases. > The current text is even more "true in essence", though. No it's not. It describes the exceptional and rare case as though it were common. It implies that using b/a-c-f together is not a practicable programming technique, whereas the opposite is true. -- Alan Mackenzie (Nuremberg, Germany).