From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Another bug with the macro counter Date: Sat, 30 Oct 2004 23:57:48 +0200 Message-ID: References: <200410210107.i9L176B10842@raven.dms.auburn.edu> <200410300238.i9U2cOD02290@raven.dms.auburn.edu> <200410300327.i9U3RWW02355@raven.dms.auburn.edu> <200410301451.i9UEpNG02900@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1099173492 3976 80.91.229.6 (30 Oct 2004 21:58:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 30 Oct 2004 21:58:12 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 30 23:58:05 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 1CO1Ea-00027N-00 for ; Sat, 30 Oct 2004 23:58:04 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CO1MV-0000Ds-Io for ged-emacs-devel@m.gmane.org; Sat, 30 Oct 2004 18:06:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CO1MM-00009X-G7 for emacs-devel@gnu.org; Sat, 30 Oct 2004 18:06:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CO1ML-00008x-W3 for emacs-devel@gnu.org; Sat, 30 Oct 2004 18:06:06 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CO1MK-00008n-OU for emacs-devel@gnu.org; Sat, 30 Oct 2004 18:06:05 -0400 Original-Received: from [195.41.46.236] (helo=pfepb.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CO1EE-0000Zs-A5 for emacs-devel@gnu.org; Sat, 30 Oct 2004 17:57:42 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepb.post.tele.dk (Postfix) with SMTP id 2C2D45EE02F; Sat, 30 Oct 2004 23:57:37 +0200 (CEST) Original-To: Luc Teirlinck In-Reply-To: <200410301451.i9UEpNG02900@raven.dms.auburn.edu> (Luc Teirlinck's message of "Sat, 30 Oct 2004 09:51:23 -0500 (CDT)") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) 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: main.gmane.org gmane.emacs.devel:29191 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:29191 Thanks for working on this problem! I don't quite follow the logic here: + (or (not (featurep 'kmacro)) + appending-to-kbd-macro + ;; never exits the or. + (setq appending-to-kbd-macro nil) + (with-no-warnings (kmacro-ring-empty-p)) + (with-no-warnings (kmacro-pop-ring))) If appending-to-kbd-macro is non-nil in the second line, you don't get to the third line which sets it to nil (i.e. it is only set to nil if it is already nil). I think it will be better if kmacro.el defines a function (defun kmacro-quit () (or appending-to-kbd-macro (kmacro-ring-empty-p) (kmacro-pop-ring)) (setq appending-to-kbd-macro nil)) which does the cleanup and then simply call this as (if (fboundp 'kmacro-quit) (kmacro-quit)) in keyboard-quit. Or even better, define a keyboard-quit-hook and add kmacro-quit to it. Here is a patch which does that: *** simple.el 25 Oct 2004 10:45:18 +0200 1.664 --- simple.el 30 Oct 2004 23:51:40 +0200 *************** *** 3910,3920 **** --- 3910,3926 ---- ;; This executes C-g typed while Emacs is waiting for a command. ;; Quitting out of a program does not go through here; ;; that happens in the QUIT macro at the C code level. + + (defvar keyboard-quit-hook nil + "Normal hook run by `keyboard-quit'. + It is called before any of the normal cleanup performed by `keyboard-quit'.") + (defun keyboard-quit () "Signal a `quit' condition. During execution of Lisp code, this character causes a quit directly. At top-level, as an editor command, this simply beeps." (interactive) + (run-hooks 'keyboard-quit-hook) (deactivate-mark) (setq defining-kbd-macro nil) (signal 'quit nil)) *** kmacro.el 19 Oct 2004 12:54:29 +0200 1.23 --- kmacro.el 30 Oct 2004 23:52:43 +0200 *************** *** 222,227 **** --- 222,239 ---- (global-set-key (vector kmacro-call-mouse-event) 'kmacro-end-call-mouse)) + ;;; Keyboard Quit Handler + + (defvar kmacro-appending-p nil) + + (defun kmacro-keyboard-quit () + (or kmacro-appending-p + (kmacro-ring-empty-p) + (kmacro-pop-ring)) + (setq kmacro-appending-p nil)) + + (add-hook 'keyboard-quit-hook 'kmacro-keyboard-quit) + ;;; Keyboard macro counter *************** *** 564,569 **** --- 576,582 ---- (if (or defining-kbd-macro executing-kbd-macro) (message "Already defining keyboard macro.") (let ((append (and arg (listp arg)))) + (setq kmacro-appending-p append) (unless append (if last-kbd-macro (let ((len (length kmacro-ring))) -- Kim F. Storm http://www.cua.dk