From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] fix/no-undo-boundary-on-secondary-buffer-change c7a6601 1/5: undo-size can count number of boundaries. Date: Tue, 22 Sep 2015 22:41:37 +0100 Message-ID: <874mim6sj2.fsf@russet.org.uk> References: <20150915152129.671.61929@vcs.savannah.gnu.org> <8761395uxx.fsf@russet.org.uk> <8737yd2iju.fsf@russet.org.uk> <87k2rizq9w.fsf@russet.org.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1442958115 12755 80.91.229.3 (22 Sep 2015 21:41:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Sep 2015 21:41:55 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 22 23:41:47 2015 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 1ZeVJq-0006Ed-Jh for ged-emacs-devel@m.gmane.org; Tue, 22 Sep 2015 23:41:46 +0200 Original-Received: from localhost ([::1]:43101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeVJp-0006Iy-SW for ged-emacs-devel@m.gmane.org; Tue, 22 Sep 2015 17:41:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeVJn-0006Is-9d for emacs-devel@gnu.org; Tue, 22 Sep 2015 17:41:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeVJj-0006El-1T for emacs-devel@gnu.org; Tue, 22 Sep 2015 17:41:43 -0400 Original-Received: from cheviot22.ncl.ac.uk ([128.240.234.22]:51881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeVJi-0006Ec-ST for emacs-devel@gnu.org; Tue, 22 Sep 2015 17:41:38 -0400 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot22.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1ZeVJi-0004hT-DG; Tue, 22 Sep 2015 22:41:38 +0100 Original-Received: from cpc6-benw10-2-0-cust45.gate.cable.virginm.net ([92.238.179.46] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1ZeVJh-0001LA-Q0; Tue, 22 Sep 2015 22:41:37 +0100 In-Reply-To: (Stefan Monnier's message of "Tue, 22 Sep 2015 08:49:16 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.22 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:190254 Archived-At: Stefan Monnier writes: >>> and do it right before we add something to the undo-list (so the test of >>> undo_list indeed tells us if this is the first new change pushed since >>> the last boundary). It should give us the same behavior but without the >>> need for that variable. >> Because, that triggers the hook only after a boundary. With >> "undo-buffer-undoably-changed", the hook is triggered after >> undo-buffer-undoably-changed is set to nil which may or may not relate >> to the addition of a boundary. And actually, currently it doesn't. > > So the question becomes: why doesn't it? Okay. So, I'll recap, and then explain the logic that I am trying to implement. I've removed the behaviour from undo.c which calls undo-boundary in a buffer whenever a change has happened in any other buffer because it breaks my use case (and others using post-command-hook). This removes a default which ensures that an undo-boundary were inserted in long-running processes periodically, so avoiding the "undo-outer-limit" situation which largely happens in buggy situations (or when a user has done something really big). So, the logic I am trying to implement (or think I have!) is: - record all buffers which have had undo-able changes in them as we go - every ten seconds check the size of the undo list, and iff it is bigger than undo-limit, and has less than 2 boundaries, add one at the start. We need 2 boundaries because the undo-list compact always leaves upto the first boundary. In reality, I have made two optimisations which make life slightly more complex. - The timer actually runs 10 seconds only after the first undoable change in any buffer, since the last time we checked (i.e. it will run once in an idle emacs). - I have not added a "undoable-change-hook" into lisp space because it will get called a lot. Rather, we have "first-undoable-change" which is called only if "undo-buffer-undoably-changed" is nil. The timer resets the buffer-local values of this to nil when it runs. I've pushed some more changes and will test further tomorrow. It's starting to behave as I expected now (my C was broken amoung other things -- initializing local variables! What's that all about?). I need to rename "undo-buffer-undoably-changed" to "-recently-changed" I think. Just to repeat everything that others have said, your patience and kindness at dealing with dumb questions is rather humbling. Good luck to you! Phil