From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.devel Subject: Re: Unbalanced change hooks (part 2) Date: Thu, 01 Sep 2016 07:40:01 +0100 Message-ID: <87wpiwxgvy.fsf@russet.org.uk> References: <20160731121642.GB2205@acm.fritz.box> <83a8gxq288.fsf@gnu.org> <87h9ag3j8c.fsf@russet.org.uk> <87pooqcolw.fsf@russet.org.uk> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1472712178 27236 195.159.176.226 (1 Sep 2016 06:42:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 1 Sep 2016 06:42:58 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 01 08:42:53 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 1bfLi5-0006AH-QS for ged-emacs-devel@m.gmane.org; Thu, 01 Sep 2016 08:42:50 +0200 Original-Received: from localhost ([::1]:57435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfLi3-0007SS-Gh for ged-emacs-devel@m.gmane.org; Thu, 01 Sep 2016 02:42:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfLgA-0006ZK-FV for emacs-devel@gnu.org; Thu, 01 Sep 2016 02:40:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfLg6-0004MP-90 for emacs-devel@gnu.org; Thu, 01 Sep 2016 02:40:49 -0400 Original-Received: from cloud103.planethippo.com ([31.216.48.48]:44677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfLg5-0004B7-U4 for emacs-devel@gnu.org; Thu, 01 Sep 2016 02:40:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=russet.org.uk; s=default; h=Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From; bh=0OduaaASaJIYHqiFfHMVxbB+9nFof/fakq+GGI4bK2k=; b=khCnVe0T/UX3T+RKGP5W1qK88z 3hwDZIgTfagfwIMVvj3XXzliOpTyN8kbcLKuAHxBgIhF5FXoAs6TrS3UkCBv+gakow4vAC/Kq8+Qo Iaq5oITx0iR/vc9AAJkW1czxbAh6D3IzVnfKO0btNinHBlfDSp+iNixo+VE3pKAAgyrzoDcguyA3Z th+swwCA8U5qEUKu3pNoR4wtL8upVbZrhjZK7kshFPyimoZelLZMLNzZyXeKKszTVXdr+OuvqJU4c dLorKIjyfzE6qTPCFrihUKLL3R09OXLDv4EwcLkSoiP6zJFNPg55949N1GUjhOnpviFg0HTg5U6yF yZSR3RxQ==; Original-Received: from cpc14-benw10-2-0-cust305.16-2.cable.virginm.net ([92.234.125.50]:58458 helo=russet.org.uk) by cloud103.planethippo.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_1) (envelope-from ) id 1bfLfQ-004EE4-52; Thu, 01 Sep 2016 07:40:04 +0100 In-Reply-To: (Stefan Monnier's message of "Tue, 30 Aug 2016 11:11:56 -0400") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud103.planethippo.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - russet.org.uk X-Get-Message-Sender-Via: cloud103.planethippo.com: authenticated_id: phillip.lord@russet.org.uk X-Authenticated-Sender: cloud103.planethippo.com: phillip.lord@russet.org.uk X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 31.216.48.48 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:207045 Archived-At: Stefan Monnier writes: >>> Note that in the subst-char-in-region you could "make it pairup" >>> yourself by hand: if you have (< (+ start length) (cdr lentic--b-c-pos)), >>> then you can just >>> >>> (let ((diff (- (cdr lentic--b-c-pos) (+ start length)))) >>> (cl-incf length diff) >>> (cl-incf end diff)) >>> >>> such that (eq (+ start length) (cdr lentic--b-c-pos)). >> So, this works because subst-char-in-region is guaranteed not to change >> the size of the region right? > > No. It works because a-c-f's arguments say "nothing was changed before > START and after END", so it's always safe (conservative) to move START > towards BOB or move END towards EOB (of course, when updating END you > also need to update LENGTH correspondingly). Okay, yes, I understand now, and yes, this should be conservative, in the sense that it works for all changes, I guess. We are making the assumption here that "start" is always consistent between b-c-f and a-c-f, and that this is never maximal in one case and minimal in the other? Phil