Return to Snippet

Revision: 27205
at May 28, 2010 10:54 by bigfaceworm


Initial Code
(defun kmacro-call-macro (arg &optional no-repeat end-macro)
  "Call the last keyboard macro that you defined with \\[kmacro-start-macro].
A prefix argument serves as a repeat count.  Zero means repeat until error.

When you call the macro, you can call the macro again by repeating
just the last key in the key sequence that you used to call this
command.  See `kmacro-call-repeat-key' and `kmacro-call-repeat-with-arg'
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)
			 last-input-event))
	repeat-key-str)
    (if end-macro
	(kmacro-end-macro arg)
      (call-last-kbd-macro arg #'kmacro-loop-setup-function))
    (when (consp arg)
      (setq arg (car arg)))
    (when (and (or (null arg) (> arg 0))
	       (setq repeat-key
		     (if (eq kmacro-call-repeat-key t)
			 repeat-key
		       kmacro-call-repeat-key)))
      (setq repeat-key-str (format-kbd-macro (vector repeat-key) nil))
      (while repeat-key
	(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))))))

Initial URL


Initial Description
From Emacs 23.1, an edited version of kmacro-call-macro that removes the call to message reminding the user that they can repeat the macro with a single key.

Initial Title
kmacro-call-macro without the message for the repeat key

Initial Tags


Initial Language
Emacs Lisp