From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: Another bug with the macro counter Date: Fri, 29 Oct 2004 21:38:24 -0500 (CDT) Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: <200410300238.i9U2cOD02290@raven.dms.auburn.edu> References: <200410210107.i9L176B10842@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1099103957 5400 80.91.229.6 (30 Oct 2004 02:39:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 30 Oct 2004 02:39:17 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 30 04:39:07 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CNj90-0008H9-00 for ; Sat, 30 Oct 2004 04:39:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CNjGt-0001ol-Cs for ged-emacs-devel@m.gmane.org; Fri, 29 Oct 2004 22:47:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CNjGm-0001oJ-9U for emacs-devel@gnu.org; Fri, 29 Oct 2004 22:47:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CNjGl-0001ne-32 for emacs-devel@gnu.org; Fri, 29 Oct 2004 22:47:07 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CNjGl-0001nb-08 for emacs-devel@gnu.org; Fri, 29 Oct 2004 22:47:07 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CNj8T-0007di-Gv for emacs-devel@gnu.org; Fri, 29 Oct 2004 22:38:33 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id i9U2cWFu026199; Fri, 29 Oct 2004 21:38:32 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id i9U2cOD02290; Fri, 29 Oct 2004 21:38:24 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: teirllm@dms.auburn.edu In-reply-to: <200410210107.i9L176B10842@raven.dms.auburn.edu> (message from Luc Teirlinck on Wed, 20 Oct 2004 20:07:06 -0500 (CDT)) 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: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:29160 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:29160 >>From my earlier message: Do `emacs -q'. C-x ( a C-x C-k C-i b RET C-x ) C-x e e e C-x ( C-g C-x e Result: a0b a1b a2b a3b a0b Of course, the newly to be defined macro got its counter reset to 0. But after we changed our mind, decided not to define a macro and quit, there is no reason why the counter for the previously defined macro should be reset to 0. Actually, that was a misinterpretation. There is a problem in the above, but not the one I suspected. The problem is that after the user quits while defining a macro, the old head of the keyboard macro ring is still the head, with a reset counter (because `kmacro-start-macro' reset it). That _same_ macro is now however _also_ the previous macro on the ring (but with the original counter) because `kmacro-start-macro' already pushed it onto the macro ring. That duplication is confusing to the user, _even_ if the user does not care about the counter. The patches below fix the bug. If they look OK, I will install them after doing some extra final checking. There is one thing that the patches below do not fix: they do not reset `kmacro-last-counter' correctly. To fix that, as well as several other bugs related to the keyboard macro counter, the elements of `kmacro-ring' should be quadruples (MACRO COUNTER LAST-COUNTER FORMAT) rather than triples (MACRO COUNTER FORMAT). If there is more than one keyboard macro _all_ the relevant information needs to be stored in `kmacro-ring'. The patches below do not do that. The patch to simple.el also quiets the compiler for `edebug-active'. This is unrelated, but while getting rid of compiler warnings related to my patch, I can quite as well get rid of all warnings. (I checked that the warnings are really false alarms.) ===File ~/kmacro.el-diff==================================== *** kmacro.el 11 Oct 2004 17:28:10 -0500 1.23 --- kmacro.el 29 Oct 2004 20:17:12 -0500 *************** *** 218,223 **** --- 218,226 ---- ;;;###autoload (global-set-key "\C-x\C-k" 'kmacro-keymap) ;;;###autoload (autoload 'kmacro-keymap "kmacro" "Keymap for keyboard macro commands." t 'keymap) + (defvar appending-to-kbd-macro nil + "Non-nil when appending to a keyboard macro definition.") + (if kmacro-call-mouse-event (global-set-key (vector kmacro-call-mouse-event) 'kmacro-end-call-mouse)) *************** *** 564,569 **** --- 567,573 ---- (if (or defining-kbd-macro executing-kbd-macro) (message "Already defining keyboard macro.") (let ((append (and arg (listp arg)))) + (setq appending-to-kbd-macro append) (unless append (if last-kbd-macro (let ((len (length kmacro-ring))) ============================================================ ===File ~/simple-diff======================================= *** simple.el 25 Oct 2004 07:40:49 -0500 1.664 --- simple.el 29 Oct 2004 20:39:08 -0500 *************** *** 865,873 **** (if (and (integerp value) (or (not (memq this-command '(eval-last-sexp eval-print-last-sexp))) (eq this-command last-command) ! (and (boundp 'edebug-active) edebug-active))) (let ((char-string ! (if (or (and (boundp 'edebug-active) edebug-active) (memq this-command '(eval-last-sexp eval-print-last-sexp))) (prin1-char value)))) (if char-string --- 865,874 ---- (if (and (integerp value) (or (not (memq this-command '(eval-last-sexp eval-print-last-sexp))) (eq this-command last-command) ! (and (boundp 'edebug-active) (with-no-warnings edebug-active)))) (let ((char-string ! (if (or (and (boundp 'edebug-active) ! (with-no-warnings edebug-active)) (memq this-command '(eval-last-sexp eval-print-last-sexp))) (prin1-char value)))) (if char-string *************** *** 3916,3921 **** --- 3917,3927 ---- At top-level, as an editor command, this simply beeps." (interactive) (deactivate-mark) + (or (not (featurep 'kmacro)) + (with-no-warnings appending-to-kbd-macro) + (kmacro-ring-empty-p) + (kmacro-pop-ring) + (with-no-warnings (setq appending-to-kbd-macro nil))) (setq defining-kbd-macro nil) (signal 'quit nil)) ============================================================