From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Unbalanced change hooks (part 2) [Documentation fix still remaining] Date: Fri, 19 Aug 2016 12:12:39 +0300 Message-ID: <834m6hdsvs.fsf@gnu.org> References: <83tweugeu9.fsf@gnu.org> <20160809163814.GD4893@acm.fritz.box> <83inv9hkjd.fsf@gnu.org> <83h9ashfgx.fsf@gnu.org> <831t1wharr.fsf@gnu.org> <83mvkaduh0.fsf@gnu.org> <20160819084526.GA1971@acm.fritz.box> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1471597973 1599 195.159.176.226 (19 Aug 2016 09:12:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 19 Aug 2016 09:12:53 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 19 11:12:49 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 1bafr7-00009p-2n for ged-emacs-devel@m.gmane.org; Fri, 19 Aug 2016 11:12:49 +0200 Original-Received: from localhost ([::1]:56341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bafr4-00011h-Ai for ged-emacs-devel@m.gmane.org; Fri, 19 Aug 2016 05:12:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bafqy-00011c-3k for emacs-devel@gnu.org; Fri, 19 Aug 2016 05:12:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bafqs-00007E-RI for emacs-devel@gnu.org; Fri, 19 Aug 2016 05:12:38 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:44049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bafqs-000076-O8; Fri, 19 Aug 2016 05:12:34 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4176 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bafqq-0007re-Rn; Fri, 19 Aug 2016 05:12:33 -0400 In-reply-to: <20160819084526.GA1971@acm.fritz.box> (message from Alan Mackenzie on Fri, 19 Aug 2016 08:45:26 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:206662 Archived-At: > Date: Fri, 19 Aug 2016 08:45:26 +0000 > Cc: Stefan Monnier , emacs-devel@gnu.org > From: Alan Mackenzie > > > One questionable place is insert-file-contents: it deliberately never > > calls the before-change-functions when it deletes portions of the > > text, only when it inserts text. I don't really understand the > > reasons behind your insisting on before-change-functions being called > > before any changes in this case, but maybe a simple way out would be > > to announce at the beginning of the function that the entire range > > between point-min and point-max is about to be changed, when REPLACE > > is non-nil. > > That might create difficulties for CC Mode. CC Mode now recognises when > b-c-f isn't called at all, but isn't, as far as I've thought it through, > prepared to deal with b-c-f with inaccurate arguments. The arguments are not inaccurate: what insert-file-contents does in that case is really replace the text between point-min and point-max with what's in the file on disk. That it includes internal optimizations which actually try to make minimal changes is just that -- an optimization. Modes that hook the changes cannot depend on internal optimizations like that. More generally, since CC mode already knows how to recalculate everything when a buffer is reverted, this should no longer be an issue. > > In message_dolog, which is called by any code which logs a message in > > *Messages*, we never call the before-change-functions for the > > *Messages* buffer, but we do call the after-change-functions for it. > > Problem or not? > > "Change Hooks" in the Elisp manual states that b-c-f and a-c-f are not > called for the *Messages* buffer. So I would say calling a-c-f here is a > bug. You are reading the manual too literally. > > This variable holds a list of functions to call when Emacs is about > > to modify a buffer. > > Somebody wanting to use b-c-f and reading that text is likely to conclude > that b-c-f is called for _every_ change, just as I did ~10 years ago. Then they will be wrong, because the text doesn't say so. > > It intentionally refrains from saying "any and all modifications", and > > instead tries to be more vague. Do you still think this is not good > > enough? Because if you do, I don't see how we can say anything more > > accurate and yet avoid misleading the reader. > > How can accurate documentation mislead? By using terminology that is not rigorously defined. Like "buffer modification", for example. You yourself say that set-buffer-multibyte shouldn't call the modification hooks, but that function surely does perform "buffer modifications" in some sense of that term.