emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another bug with the macro counter


From: Kim F. Storm
Subject: Re: Another bug with the macro counter
Date: Sat, 30 Oct 2004 23:57:48 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

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 <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]