From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: (insert ?\n) spuriously calls before-change-functions twice. Help! Date: Wed, 6 Jan 2010 13:05:21 +0000 Message-ID: <20100106130521.GA2447@muc.de> References: <20100105110954.GA2639@muc.de> <20100105173158.GB2639@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1262782769 27792 80.91.229.12 (6 Jan 2010 12:59:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Jan 2010 12:59:29 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 06 13:59:22 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NSVTt-00073e-DJ for ged-emacs-devel@m.gmane.org; Wed, 06 Jan 2010 13:59:21 +0100 Original-Received: from localhost ([127.0.0.1]:57675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSVTt-0005k7-GH for ged-emacs-devel@m.gmane.org; Wed, 06 Jan 2010 07:59:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSVTn-0005iu-Uf for emacs-devel@gnu.org; Wed, 06 Jan 2010 07:59:15 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSVTj-0005dR-8p for emacs-devel@gnu.org; Wed, 06 Jan 2010 07:59:15 -0500 Original-Received: from [199.232.76.173] (port=44458 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSVTj-0005dJ-4g for emacs-devel@gnu.org; Wed, 06 Jan 2010 07:59:11 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:1715 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NSVTi-0000qd-Hn for emacs-devel@gnu.org; Wed, 06 Jan 2010 07:59:10 -0500 Original-Received: (qmail 94952 invoked by uid 3782); 6 Jan 2010 12:59:07 -0000 Original-Received: from acm.muc.de (pD9E52107.dip.t-dialin.net [217.229.33.7]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Wed, 06 Jan 2010 13:59:06 +0100 Original-Received: (qmail 2540 invoked by uid 1000); 6 Jan 2010 13:05:21 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:119516 Archived-At: Hi, Stefan, On Tue, Jan 05, 2010 at 02:52:37PM -0500, Stefan Monnier wrote: > > I think I've tracked down what's happening. After inserting the ?\n (any > > other character is just the same), Emacs clears any text properties from > > the new character by calling set_properties. This, in its turn, invokes > > before-change-functions. A more detailed call stack is: > Sounds like a bug indeed. > > There doesn't seem to be any system in where the two change hooks are > > invoked. For example, insert directly calls signal_after_change, yet not > > signal_before_change; surely invocations of these should be paired. > Agreed. Patch very welcome, I'll look at this. It looks impractical to change the source to do this. signal_after_change seems usually to be paired with modify_region or prepare_to_modify_buffer. But I'll certainly fix the current bug, and check (as far as I can) for other circumstances it might happen. > > For CC Mode, I will put in a test for two consecutive invocations of > > before-change-functions without an after-change-functions between > > them. In such a case, I then ignore the second invocation. I think. > Even if we fix the bug, there can be any number of reasons why the two > hooks may occasionally not be paired, ..... Really? I would have thought they should be rigorously paired, without any "recursive" invocations in-between (barring elisp code doing this deliberately). > .... so your hooks should be robust against such situations. IOW it's > best to try and avoid relying in the after-hook on info passed from the > before hook. Haven't we discussed this before at some time? ;-) > Stefan -- Alan Mackenzie (Nuremberg, Germany).