;;; kmacro.el --- enhanced keyboard macros
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006,
+;; 2007 Free Software Foundation, Inc.
;; Author: Kim F. Storm <storm@cua.dk>
;; Keywords: keyboard convenience
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
(defun kmacro-insert-counter (arg)
"Insert macro counter and increment with ARG or 1 if missing.
-With \\[universal-argument], insert previous kmacro-counter (but do not modify counter)."
+With \\[universal-argument], insert previous `kmacro-counter' (but do not modify counter)."
(interactive "P")
(if kmacro-initial-counter-value
(setq kmacro-counter kmacro-initial-counter-value
(defun kmacro-set-counter (arg)
- "Set kmacro-counter to ARG or prompt if missing.
+ "Set `kmacro-counter' to ARG or prompt if missing.
With \\[universal-argument] prefix, reset counter to its value prior to this iteration of the macro."
(interactive "NMacro counter value: ")
(if (not (or defining-kbd-macro executing-kbd-macro))
(defun kmacro-call-ring-2nd (arg)
- "Execute second keyboard macro at in macro ring."
+ "Execute second keyboard macro in macro ring."
(interactive "P")
(unless (kmacro-ring-empty-p)
(kmacro-exec-ring-item (car kmacro-ring) arg)))
(defun kmacro-call-ring-2nd-repeat (arg)
- "Execute second keyboard macro at in macro ring.
+ "Execute second keyboard macro in macro ring.
This is like `kmacro-call-ring-2nd', but allows repeating macro commands
without repeating the prefix."
(interactive "P")
(unless executing-kbd-macro
(end-kbd-macro arg #'kmacro-loop-setup-function)
(when (and last-kbd-macro (= (length last-kbd-macro) 0))
+ (setq last-kbd-macro nil)
(message "Ignore empty macro")
- (kmacro-pop-ring))))
+ ;; Don't call `kmacro-ring-empty-p' to avoid its messages.
+ (while (and (null last-kbd-macro) kmacro-ring)
+ (kmacro-pop-ring1)))))
;;;###autoload
When defining/executing macro, inserts macro counter and increments
the counter with ARG or 1 if missing. With \\[universal-argument],
-inserts previous kmacro-counter (but do not modify counter).
+inserts previous `kmacro-counter' (but do not modify counter).
The macro counter can be modified via \\[kmacro-set-counter] and \\[kmacro-add-counter].
The format of the counter can be modified via \\[kmacro-set-format]."
ok cmd)
(when (= (length key-seq) 1)
(let ((ch (aref key-seq 0)))
- (if (or (and (>= ch ?0) (<= ch ?9))
- (and (>= ch ?A) (<= ch ?Z)))
+ (if (and (integerp ch)
+ (or (and (>= ch ?0) (<= ch ?9))
+ (and (>= ch ?A) (<= ch ?Z))))
(setq key-seq (concat "\C-x\C-k" key-seq)
ok t))))
(when (and (not (equal key-seq "\a"))
(defvar kmacro-step-edit-prefix-commands
'(universal-argument universal-argument-more universal-argument-minus
digit-argument negative-argument)
- "Commands which builds up a prefix arg for the current command")
+ "Commands which build up a prefix arg for the current command.")
(defun kmacro-step-edit-prompt (macro index)
;; Show step-edit prompt