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 f59d1be: Move undo amalgamation to lisp. Date: Mon, 05 Oct 2015 11:15:34 -0400 Message-ID: References: <20151005134118.10933.50859@vcs.savannah.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1444058195 15738 80.91.229.3 (5 Oct 2015 15:16:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Oct 2015 15:16:35 +0000 (UTC) Cc: Phillip Lord To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 05 17:16:22 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 1Zj7Uz-000366-3f for ged-emacs-devel@m.gmane.org; Mon, 05 Oct 2015 17:16:21 +0200 Original-Received: from localhost ([::1]:46212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zj7Uw-00075q-QT for ged-emacs-devel@m.gmane.org; Mon, 05 Oct 2015 11:16:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zj7UM-00072H-FC for emacs-devel@gnu.org; Mon, 05 Oct 2015 11:15:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zj7UH-0001A9-9v for emacs-devel@gnu.org; Mon, 05 Oct 2015 11:15:42 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:16700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zj7UH-00019X-6D for emacs-devel@gnu.org; Mon, 05 Oct 2015 11:15:37 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CsCwA731xV/3aQs2tcgxCEAsEMCYdLBAICgTw5FAEBAQEBAQGBCkEFg10BAQRWIxALNAcLFBgNiGPPIwEBAQcCAR+LOoUFBxaEFwW1BCOCO4FZIoJ4AQEB X-IPAS-Result: A0CsCwA731xV/3aQs2tcgxCEAsEMCYdLBAICgTw5FAEBAQEBAQGBCkEFg10BAQRWIxALNAcLFBgNiGPPIwEBAQcCAR+LOoUFBxaEFwW1BCOCO4FZIoJ4AQEB X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="167556537" Original-Received: from 107-179-144-118.cpe.teksavvy.com (HELO pastel.home) ([107.179.144.118]) by ironport2-out.teksavvy.com with ESMTP; 05 Oct 2015 11:15:35 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id B2C2A62838; Mon, 5 Oct 2015 11:15:34 -0400 (EDT) In-Reply-To: (Phillip Lord's message of "Mon, 05 Oct 2015 13:41:19 +0000") 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:190937 Archived-At: > +(defun undo-auto-pre-command-hook() > + (when (and (eq last-command 'self-insert-command) > + (eq this-command 'self-insert-command)) I think this code should be called from self-insert-command rather than from pre-command-hook. And it should also be called from delete-char. > + ;; As last-command was s-i-c, there should be "insert" cons just > + ;; before this. We need to check that there have not been too many insertions > + (let ((last-before-nil > + (cadr buffer-undo-list))) > + (when > + (> 20 > + (- (cdr last-before-nil) > + (car last-before-nil))) We don't actually know that (cdr last-before-nil) and (car last-before-nil) are numbers. The previous self-insert-command might have performed all kinds of buffer modifications (via abbrev-expansion, post-self-insert-hook, ...). Stefan