From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Add a comment to simple.el to explain the workings of `undo'. Date: Tue, 21 Oct 2008 21:09:43 +0000 Message-ID: <20081021210943.GB12051@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1224622830 2530 80.91.229.12 (21 Oct 2008 21:00:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Oct 2008 21:00:30 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 21 23:01:30 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KsOM5-0006JQ-7x for ged-emacs-devel@m.gmane.org; Tue, 21 Oct 2008 23:01:29 +0200 Original-Received: from localhost ([127.0.0.1]:51198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsOKz-00035R-QF for ged-emacs-devel@m.gmane.org; Tue, 21 Oct 2008 17:00:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KsOKu-00035K-Cm for emacs-devel@gnu.org; Tue, 21 Oct 2008 17:00:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KsOKt-000357-FQ for emacs-devel@gnu.org; Tue, 21 Oct 2008 17:00:15 -0400 Original-Received: from [199.232.76.173] (port=42981 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsOKt-000354-9R for emacs-devel@gnu.org; Tue, 21 Oct 2008 17:00:15 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:1669 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KsOKs-0005eU-Oh for emacs-devel@gnu.org; Tue, 21 Oct 2008 17:00:15 -0400 Original-Received: (qmail 40881 invoked by uid 3782); 21 Oct 2008 21:00:12 -0000 Original-Received: from acm.muc.de (pD9E52C09.dip.t-dialin.net [217.229.44.9]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Tue, 21 Oct 2008 23:00:11 +0200 Original-Received: (qmail 20027 invoked by uid 1000); 21 Oct 2008 21:09:43 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:104784 Archived-At: Hi, Emacs! I've suffered some pain over the last couple of days trying to make sense of `undo'. The things which were bugging me were: (i) Why does undo copy buffer-undo-list to pending-undo-list before calling `primitive-undo' rather than just using buffer-undo-list directly? (ii) What on Earth is `undo' doing, after the call to `undo-more', comparing (car buffer-undo-list) to nil, when it always has this nil, and clearly "hasn't been changed" (tm) by `undo-more'. Had the following short comment already been in simple.el, I would have had little difficulty understanding `undo': 2008-10-21 Alan Mackenzie * simple.el (undo-more): Add comment explaining the operations on pending-undo-list and buffer-undo-list. *** /home/acm/emacs/emacs/lisp/simple.el~ 2008-10-21 20:37:17.466580872 +0000 --- /home/acm/emacs/emacs/lisp/simple.el 2008-10-21 20:49:24.843002848 +0000 *************** *** 1725,1730 **** --- 1725,1733 ---- (error (concat "No further undo information" (and undo-in-region " for region")))) (let ((undo-in-progress t)) + ;; Note: The following, while pulling elements off + ;; `pending-undo-list' will call primitive change functions which + ;; will push more elements onto `buffer-undo-list'. (setq pending-undo-list (primitive-undo n pending-undo-list)) (if (null pending-undo-list) (setq pending-undo-list t)))) Can I install this, please? -- Alan Mackenzie (Nuremberg, Germany).