X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/4c36be58ca2b4777a5e7bf0d3e692cfd9fa1aea3..758c81e87ded2bad9f5a5a6683fb498965eb508c:/lisp/kmacro.el diff --git a/lisp/kmacro.el b/lisp/kmacro.el index eea3009faf..ffc97085a6 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -1,6 +1,6 @@ ;;; kmacro.el --- enhanced keyboard macros -;; Copyright (C) 2002-2011 Free Software Foundation, Inc. +;; Copyright (C) 2002-2012 Free Software Foundation, Inc. ;; Author: Kim F. Storm ;; Keywords: keyboard convenience @@ -231,12 +231,12 @@ macro to be executed before appending to it." ;;; Keyboard macro counter (defvar kmacro-counter 0 - "*Current keyboard macro counter.") + "Current keyboard macro counter.") (defvar kmacro-default-counter-format "%d") (defvar kmacro-counter-format "%d" - "*Current keyboard macro counter format.") + "Current keyboard macro counter format.") (defvar kmacro-counter-format-start kmacro-counter-format "Macro format at start of macro execution.") @@ -625,8 +625,10 @@ for details on how to adjust or disable this behavior. To make a macro permanent so you can call it even after defining others, use \\[kmacro-name-last-macro]." (interactive "p") - (let ((repeat-key (and (null no-repeat) - (> (length (this-single-command-keys)) 1) + (let ((repeat-key (and (or (and (null no-repeat) + (> (length (this-single-command-keys)) 1)) + ;; Used when we're in the process of repeating. + (eq no-repeat 'repeating)) last-input-event)) repeat-key-str) (if end-macro @@ -640,24 +642,16 @@ others, use \\[kmacro-name-last-macro]." repeat-key kmacro-call-repeat-key))) (setq repeat-key-str (format-kbd-macro (vector repeat-key) nil)) - (while repeat-key - ;; Issue a hint to the user, if the echo area isn't in use. - (unless (current-message) - (message "(Type %s to repeat macro%s)" - repeat-key-str - (if (and kmacro-call-repeat-with-arg - arg (> arg 1)) - (format " %d times" arg) ""))) - (if (equal repeat-key (read-event)) - (progn - (clear-this-command-keys t) - (call-last-kbd-macro (and kmacro-call-repeat-with-arg arg) - #'kmacro-loop-setup-function) - (setq last-input-event nil)) - (setq repeat-key nil))) - (when last-input-event - (clear-this-command-keys t) - (setq unread-command-events (list last-input-event)))))) + ;; Can't use the `keep-pred' arg because this overlay keymap needs to be + ;; removed during the next run of the kmacro (i.e. we need to add&remove + ;; this overlay-map at each repetition). + (set-temporary-overlay-map + (let ((map (make-sparse-keymap))) + (define-key map (vector repeat-key) + `(lambda () (interactive) + (kmacro-call-macro ,(and kmacro-call-repeat-with-arg arg) + 'repeating))) + map))))) ;;; Combined function key bindings: @@ -747,7 +741,7 @@ If kbd macro currently being defined end it before activating it." ;; Create a separate keymap installed as a minor-mode keymap (e.g. in ;; the emulation-mode-map-alists) in which macro bindings are made ;; independent of any other bindings. When first binding is made, -;; the kemap is created, installed, and enabled. Key seq. C-x C-k + +;; the keymap is created, installed, and enabled. Key seq. C-x C-k + ;; can then be used to toggle the use of this keymap on and off. ;; This means that it would be safe(r) to bind ordinary keys like ;; letters and digits, provided that we inhibit the keymap while