From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Phillip Lord" Newsgroups: gmane.emacs.devel Subject: Re: Thinking about changed buffers Date: Tue, 29 Mar 2016 14:14:08 +0100 Message-ID: <2d55f05e4ba00afeb3f7269953eb0e13.squirrel@cloud103.planethippo.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1459257323 32175 80.91.229.3 (29 Mar 2016 13:15:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Mar 2016 13:15:23 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 29 15:15:14 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aktUF-00066P-IF for ged-emacs-devel@m.gmane.org; Tue, 29 Mar 2016 15:15:11 +0200 Original-Received: from localhost ([::1]:46688 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aktUE-0001ys-I4 for ged-emacs-devel@m.gmane.org; Tue, 29 Mar 2016 09:15:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aktTz-0001yn-A7 for emacs-devel@gnu.org; Tue, 29 Mar 2016 09:14:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aktTu-0002Xg-A7 for emacs-devel@gnu.org; Tue, 29 Mar 2016 09:14:55 -0400 Original-Received: from cloud103.planethippo.com ([31.216.48.48]:57358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aktTt-0002RE-Vt for emacs-devel@gnu.org; Tue, 29 Mar 2016 09:14:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=russet.org.uk; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:To:From:Subject:Date:References:In-Reply-To:Message-ID; bh=M++JIXdo2leshWYJLkGW+tXBP7eYf+5M4aVrsKJ+5MM=; b=PCDh0nwktPwDyS7HEdtVZPEBxs y+tsnfcKukLA26TVFH4xQnqGoVkfkGKiJZmneD4rGHfQ+9yVyWy5BcwmJdIPXpC3/urjRzaOHP1+n 7dNFUszKljYR2R5Ixh3HkhqK/fAkzr9yeLfPL6oiAxqGQc/Ob6lcz7Yee0P1TdruhR53Wg/srAbr3 GfkWL4p+bhvzVycusKmRBx8ytzsEcCldyYOPkr16Q/3NqZT7M5EKXgCs9ZAoFdOLKw7mztJWWawrs Q5bqiGUFwj+C0g9ScFGxlkB/3rI/Xtf1s1mD7fcf48FsMnJOpnB4HZPY86Lsr7fJ3Y3bmzIoygeeK qPuZW4UQ==; Original-Received: from [127.0.0.1] (port=50493 helo=cloud103.planethippo.com) by cloud103.planethippo.com with esmtpa (Exim 4.86_1) (envelope-from ) id 1aktTE-002b47-BC for emacs-devel@gnu.org; Tue, 29 Mar 2016 14:14:08 +0100 Original-Received: from 92.28.198.187 ([92.28.198.187]) (SquirrelMail authenticated user phillip.lord@russet.org.uk) by cloud103.planethippo.com with HTTP; Tue, 29 Mar 2016 14:14:08 +0100 In-Reply-To: User-Agent: SquirrelMail/1.5.2 [SVN] 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.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:202384 Archived-At: On Mon, March 28, 2016 6:31 pm, Lars Magne Ingebrigtsen wrote: > One idea that popped up is that whenever we mark a buffer as unchanged > (that is, `(set-buffer-modified-p nil)', we save the byte size of the > buffer and a cryptographic hash of the buffer. Then `buffer-modified-p' > would simply see whether either the size had changed, and if not, whether > the hash had changed. If both are identical, then the buffer hasn't > changed. > Rather than doing this in general, why not have a "with-potentially-unmodified" macro, which calculates this hash and restores buffer-modified-p if no changes have happened. This would solve the "fill-paragraph" problem. Although, I would worry about the implications for the before and after-change hooks. fill-paragraph is already problematic here because before and after changes hooks are not necessarily consistent. In the case where no changes happen, would we expect before and after change hook to run? Because they would have to, as we do not know whether the buffer will change before we change. The only solution I can see for fill-paragraph is to copy the paragraph to a temp buffer, fill that, check whether it has changed, then if it has, signal before-change, copy the changed paragraph back, signal after change. If it has not changed, then fill-paragraph becomes a no-op. Phil