Mercurial > emacs
changeset 57439:e12200cc9b00
(kmacro-insert-counter, kmacro-add-counter): Use and
reset kmacro-initial-counter-value if set.
(kmacro-set-counter): Only set kmacro-counter if defining or executing
macro. Set kmacro-initial-counter-value otherwise. Never set both.
(kmacro-display): Show macro counter if non-zero.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Mon, 11 Oct 2004 22:13:20 +0000 |
parents | 0326440c511a |
children | c73d8ac83f10 |
files | lisp/kmacro.el |
diffstat | 1 files changed, 18 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/kmacro.el Mon Oct 11 22:02:16 2004 +0000 +++ b/lisp/kmacro.el Mon Oct 11 22:13:20 2004 +0000 @@ -248,7 +248,9 @@ "Insert macro counter and increment with ARG or 1 if missing. With \\[universal-argument], insert previous kmacro-counter (but do not modify counter)." (interactive "P") - (setq kmacro-initial-counter-value nil) + (if kmacro-initial-counter-value + (setq kmacro-counter kmacro-initial-counter-value + kmacro-initial-counter-value nil)) (if (and arg (listp arg)) (insert (format kmacro-counter-format kmacro-last-counter)) (insert (format kmacro-counter-format kmacro-counter)) @@ -275,23 +277,23 @@ "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: ") - (setq kmacro-last-counter kmacro-counter - kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) - kmacro-counter-value-start - arg)) - ;; setup initial macro counter value if we are not executing a macro. - (setq kmacro-initial-counter-value - (and (not (or defining-kbd-macro executing-kbd-macro)) - kmacro-counter)) - (unless executing-kbd-macro - (kmacro-display-counter))) + (if (not (or defining-kbd-macro executing-kbd-macro)) + (kmacro-display-counter (setq kmacro-initial-counter-value arg)) + (setq kmacro-last-counter kmacro-counter + kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) + kmacro-counter-value-start + arg)) + (unless executing-kbd-macro + (kmacro-display-counter)))) (defun kmacro-add-counter (arg) "Add numeric prefix arg (prompt if missing) to macro counter. With \\[universal-argument], restore previous counter value." (interactive "NAdd to macro counter: ") - (setq kmacro-initial-counter-value nil) + (if kmacro-initial-counter-value + (setq kmacro-counter kmacro-initial-counter-value + kmacro-initial-counter-value nil)) (let ((last kmacro-last-counter)) (setq kmacro-last-counter kmacro-counter kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) @@ -394,7 +396,10 @@ (m (format-kbd-macro macro)) (l (length m)) (z (and nil trunc (> l x)))) - (message (format "%s: %s%s" (or descr "Macro") + (message (format "%s%s: %s%s" (or descr "Macro") + (if (= kmacro-counter 0) "" + (format " [%s]" + (format kmacro-counter-format-start kmacro-counter))) (if z (substring m 0 (1- x)) m) (if z "..." "")))) (message (or empty "No keyboard macros defined"))))