From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] fix/no-undo-boundary-on-secondary-buffer-change e5ff575 2/2: Add a timer to ensure undo-boundaries in buffers. Date: Sun, 06 Sep 2015 19:03:38 -0400 Message-ID: References: <20150821093606.11577.60349@vcs.savannah.gnu.org> <87d1y272f9.fsf@russet.org.uk> <87a8t6jbuy.fsf@russet.org.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1441580643 14886 80.91.229.3 (6 Sep 2015 23:04:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Sep 2015 23:04:03 +0000 (UTC) Cc: emacs-devel@gnu.org To: phillip.lord@russet.org.uk (Phillip Lord) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 07 01:03:51 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 1ZYiyT-0004IT-3Y for ged-emacs-devel@m.gmane.org; Mon, 07 Sep 2015 01:03:49 +0200 Original-Received: from localhost ([::1]:51182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYiyS-0004pK-TQ for ged-emacs-devel@m.gmane.org; Sun, 06 Sep 2015 19:03:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYiyP-0004p2-55 for emacs-devel@gnu.org; Sun, 06 Sep 2015 19:03:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYiyK-0005ec-67 for emacs-devel@gnu.org; Sun, 06 Sep 2015 19:03:45 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:31737) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYiyK-0005eW-2F for emacs-devel@gnu.org; Sun, 06 Sep 2015 19:03:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CtCwA731xV/xGkpUVcgxCEAsEMCYdLBAICgTw5FAEBAQEBAQGBCkEFg10BAQMBViMFCws0BwsUGA2IWwjPIwEBCAIBH4s6hC1YB4QtAQSQNKMLgUUjgWZVgVkigTWBQwEBAQ X-IPAS-Result: A0CtCwA731xV/xGkpUVcgxCEAsEMCYdLBAICgTw5FAEBAQEBAQGBCkEFg10BAQMBViMFCws0BwsUGA2IWwjPIwEBCAIBH4s6hC1YB4QtAQSQNKMLgUUjgWZVgVkigTWBQwEBAQ X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="162695174" Original-Received: from 69-165-164-17.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.165.164.17]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Sep 2015 19:03:39 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id DDE2DAE042; Sun, 6 Sep 2015 19:03:38 -0400 (EDT) In-Reply-To: <87a8t6jbuy.fsf@russet.org.uk> (Phillip Lord's message of "Tue, 01 Sep 2015 18:19:49 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:189658 Archived-At: > Iff I do this, I would like to keep into elisp as much as possible. Yes, that's generally what we try to do. > I guess adding undo-pre-extend and undo-post-extend hooks should do the > trick? Not sure. There's also the desire to keep costs down. Adding undo elements can happen *very often* in some cases (for some commands which perform many changes), so the case of adding an undo record in a buffer that already has had other undo records added since the last undo boundary should be fast and I'd rather not run undo-pre-extend and undo-post-extend hooks in that case. So I think we should have a hook run whenever we push the first change after a boundary. That would let you (from Elisp) add the buffer to some set of "modified" buffers, start timers, etc... > Then anyone could switch this behaviour off. Then undo-outer-limit would > become the final backstop. Sounds good. > Two issues. simple.el does not depend on timer, so I am not clear where > to add this. I think you can add it to simple.el for a first attempt (timer.el is preloaded anyway). Bootstrap is always slightly delicate, and it's difficult to guess in advance what problems will show up and how to best fix them. So just assume the gods will be with you for now, and if they don't show up, we'll see what needs to be done. > And, I am aware that `buffer-undo-list' is just a list. Anyone can > change it anywhere in lisp, which would make the hooks difficult > to enforce. It's a problem in theory, indeed, but in practice it should be mostly a non-issue. IOW, I wouldn't worry about it. > Just to clarify, you are suggesting a post-command add undo-boundary, > rather than post-change (i.e. potentially many times per command)? I > would need to think on this. I'm not suggesting it: that's what the code does currently (look for Fundo_boundary in src/keyboard.c). Stefan