From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Richard Copley Newsgroups: gmane.emacs.devel Subject: Re: Unbalanced change hooks (part 1) Date: Tue, 2 Aug 2016 10:19:47 +0100 Message-ID: References: <20160731101617.GA2205@acm.fritz.box> <8337mnoq4x.fsf@gnu.org> NNTP-Posting-Host: blaine Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1470130185 16457 195.159.176.226 (2 Aug 2016 09:29:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 2 Aug 2016 09:29:45 +0000 (UTC) Cc: =?UTF-8?Q?=C3=93scar_Fuentes?= , Alan Mackenzie , Emacs Development To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 02 11:29:40 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 1bUW15-0001WF-Tk for ged-emacs-devel@m.gmane.org; Tue, 02 Aug 2016 11:29:40 +0200 Original-Received: from localhost ([::1]:54851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUW0C-0005AE-L3 for ged-emacs-devel@m.gmane.org; Tue, 02 Aug 2016 05:28:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUVs9-0006i1-Rs for emacs-devel@gnu.org; Tue, 02 Aug 2016 05:20:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUVs6-00010c-QE for emacs-devel@gnu.org; Tue, 02 Aug 2016 05:20:24 -0400 Original-Received: from mail-vk0-x22f.google.com ([2607:f8b0:400c:c05::22f]:35171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUVs2-0000z3-BH; Tue, 02 Aug 2016 05:20:18 -0400 Original-Received: by mail-vk0-x22f.google.com with SMTP id w127so118193786vkh.2; Tue, 02 Aug 2016 02:20:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Y920AUZVMc8L1k8vhgtauaYlIAp2eS9fg5ZP3ZDYfRc=; b=zg9BL0Wlug5vV/SLF/OM8pViO8WAuqHHGM0kxECg2VupjRrqg1g5Gpgudkn0PEicYh ZaV6y2ExV7iSiaRptJp9KVXc8hXKr4PUP1DNGtdvWYlBQYQ630j1aITSr5AFn1hHtiK8 xg8qTRWvDug5op9FoL9hNqY2X5V0Vka1XuMEFcdAQfAYcqX8ROLMzXFssZX1R2jynBM2 J0HYl11rZfnBjdz5gu58wjfNtOWNqJapW+XvwF8GrMw528V2zobOkb6UZztHTqhNlm1E yIvAm960EoYRxLCzYfS6Wbpwl488O5QdRwPpwBQZcWHsLDJD1tLfXNunPIV19k3Xk7SL I54w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Y920AUZVMc8L1k8vhgtauaYlIAp2eS9fg5ZP3ZDYfRc=; b=Jkpvl5s8FvLmchpwCs17JJgBXE9QCLoEZtYulNtezDzJzMFDyqk0jBwlw+Y866McjK Ir6wxCCw+2ugcnsqpuP1uVrhk98stsUYCLUb9aHAciwa+h78rOt3KT29kwM4zGr/ulsi JbqzyDXtUkeL/otp4zJgSbgxXnRd53YxkhESNyBatuFS6zJJCJff/uiDjZSvrh5WPJZS hqEx8ma+vysFfadip7nokSKzHxW0LbLeCxTgKf1En+72A5C5A0C7wLkecQQjD8/CnuPl ZCAwLTRR76NCwL5PKEZEzzPJjLOn3Kn9j5D4N2O1ldQzS+gRulmSAjECRrVaq4Ulsru1 VNBQ== X-Gm-Message-State: AEkoout4RRaAvBc9e3BGUQlco5XnoolA7FzfsrX0A2lTBJVl3x7bpr+mq3tqi1lMilsF7wcoshSIjb+6V4/J5g== X-Received: by 10.31.157.139 with SMTP id g133mr23983810vke.49.1470129617734; Tue, 02 Aug 2016 02:20:17 -0700 (PDT) Original-Received: by 10.176.1.41 with HTTP; Tue, 2 Aug 2016 02:19:47 -0700 (PDT) In-Reply-To: <8337mnoq4x.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c05::22f 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:206343 Archived-At: On 2 August 2016 at 03:34, Eli Zaretskii wrote: >> From: Richard Copley >> Date: Mon, 1 Aug 2016 21:13:01 +0100 >> Cc: =C3=93scar Fuentes , >> Emacs Development >> >> > diff --git a/src/fileio.c b/src/fileio.c >> > index b1f9d3c..0431cbc 100644 >> > --- a/src/fileio.c >> > +++ b/src/fileio.c >> > @@ -3440,6 +3440,7 @@ by calling `format-decode', which see. */) >> > /* SAME_AT_END_CHARPOS counts characters, because >> > restore_window_points needs the old character count. */ >> > ptrdiff_t same_at_end_charpos =3D ZV; >> > + bool run_change_hooks; >> > >> > if (current_buffer->base_buffer && ! NILP (visit)) >> > error ("Cannot do file visiting in an indirect buffer"); >> > @@ -4077,7 +4078,9 @@ by calling `format-decode', which see. */) >> > /* For a special file, all we can do is guess. */ >> > total =3D READ_BUF_SIZE; >> > >> > - if (NILP (visit) && total > 0) >> > + run_change_hooks =3D ((NILP (visit) || !NILP (replace)) >> > + && total > 0); >> > + if (run_change_hooks) >> > { >> > if (!NILP (BVAR (current_buffer, file_truename)) >> > /* Make binding buffer-file-name to nil effective. */ >> > @@ -4313,8 +4316,7 @@ by calling `format-decode', which see. */) >> > /* Call after-change hooks for the inserted text, aside from the ca= se >> > of normal visiting (not with REPLACE), which is done in a new bu= ffer >> > "before" the buffer is changed. */ >> > - if (inserted > 0 && total > 0 >> > - && (NILP (visit) || !NILP (replace))) >> > + if (run_change_hooks) >> > { >> > signal_after_change (PT, 0, inserted); >> > update_compositions (PT, PT, CHECK_BORDER); >> > >> > >> > Unfortunately, this amendment, by itself, doesn't fix #240[79]4, since >> > there are other causes for the change hooks being improperly invoked. >> > >> > -- >> > Alan Mackenzie (Nuremberg, Germany). >> >> LGTM. It's hard to imagine anyone relying on the before-change hooks >> _not_ being run, so it should be safe, at least, to make this change. > > That code is almost never run when REPLACE is non-nil, so doing that > won't help. See an earlier message that explained why. Thanks Eli, I saw it. It's not the sort of discussion I care to get involve= d in.