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) Date: Mon, 8 Aug 2016 14:36:14 +0000 Message-ID: <20160808143614.GA7208@acm.fritz.box> References: <20160731121642.GB2205@acm.fritz.box> <20160802101549.GA2328@acm.fritz.box> <83r3a7md69.fsf@gnu.org> <20160802165545.GD2328@acm.fritz.box> <83fuqnm6og.fsf@gnu.org> <83eg67m3aq.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 1470667522 1707 195.159.176.226 (8 Aug 2016 14:45:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 8 Aug 2016 14:45:22 +0000 (UTC) User-Agent: Mutt/1.5.24 (2015-08-30) Cc: ofv@wanadoo.es, rcopley@gmail.com, rms@gnu.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 08 16:45:18 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 1bWlnh-0006yF-JQ for ged-emacs-devel@m.gmane.org; Mon, 08 Aug 2016 16:45:09 +0200 Original-Received: from localhost ([::1]:57859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWlne-00014I-Fr for ged-emacs-devel@m.gmane.org; Mon, 08 Aug 2016 10:45:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWlfl-00026C-Le for emacs-devel@gnu.org; Mon, 08 Aug 2016 10:37:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWlfg-0000OO-IR for emacs-devel@gnu.org; Mon, 08 Aug 2016 10:36:56 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:46367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWlfg-0000Me-8H for emacs-devel@gnu.org; Mon, 08 Aug 2016 10:36:52 -0400 Original-Received: (qmail 82779 invoked by uid 3782); 8 Aug 2016 14:36:49 -0000 Original-Received: from acm.muc.de (p4FC46EDC.dip0.t-ipconnect.de [79.196.110.220]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 08 Aug 2016 16:36:47 +0200 Original-Received: (qmail 8051 invoked by uid 1000); 8 Aug 2016 14:36:14 -0000 Content-Disposition: inline In-Reply-To: <83eg67m3aq.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:206484 Archived-At: Hello, Eli. On Tue, Aug 02, 2016 at 09:30:37PM +0300, Eli Zaretskii wrote: > > Date: Tue, 02 Aug 2016 20:17:35 +0300 > > From: Eli Zaretskii > > Cc: ofv@wanadoo.es, rcopley@gmail.com, rms@gnu.org, emacs-devel@gnu.org > > > Anyhow, it's not just CC Mode. As already discussed, there are 13 other > > > files which use before-change-functions, and some of these uses are > > > going to assume it works as documented, just as CC Mode did. Sporadic > > > failures are going to occur in some of these other places, due to those > > > hook functions sometimes not being called. > > I will believe that when I see specific bug reports about those other > > packages. > Btw, I'm slowly but surely arriving to the conclusion that the > problems we are discussing can only happen when insert-file-contents > is called with VISIT and REPLACE non-nil, i.e. when reverting a > buffer. Do we have any evidence to the contrary? If we do, can > someone show or point to such contradicting evidence? > If my conclusion is correct, then we should probably focus on this > particular use case and look for a solution for it, as opposed to > trying to solve some more general problem that seems not to exist. It > might be much easier and simpler. Using buffer-undo-list temporarily to reverse a change and run c-before-change seems to work well when the undo list is enabled. When it isn't enabled, I run into problems which don't look like being solved easily. If you're right in supposing that only insert-file-contents with those particular parameters can cause the omission of the before-change-functions call, then a solution would be for CC Mode to advise those commands which call insert-f-c this way. That advice would cause the command to test and clear a flag set by CC Mode, and if it was non-nil, to repeat the command. Repeating find-file and revert-buffer in these circumstances appears to work. -- Alan Mackenzie (Nuremberg, Germany).