diff options
| author | Kim F. Storm | 2004-10-11 22:13:20 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-10-11 22:13:20 +0000 |
| commit | 52996e8c2f6bce18dd48ac5a23a3c83666951ccc (patch) | |
| tree | eb034b2057c46da8117cb74fc96dd7e61922cc61 | |
| parent | 18c2e7918851db603d60a4d77b2716a49cda624b (diff) | |
| download | emacs-52996e8c2f6bce18dd48ac5a23a3c83666951ccc.tar.gz emacs-52996e8c2f6bce18dd48ac5a23a3c83666951ccc.zip | |
(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.
| -rw-r--r-- | lisp/kmacro.el | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/lisp/kmacro.el b/lisp/kmacro.el index b2226d4a895..2b4cbcaf323 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el | |||
| @@ -248,7 +248,9 @@ macro to be executed before appending to it." | |||
| 248 | "Insert macro counter and increment with ARG or 1 if missing. | 248 | "Insert macro counter and increment with ARG or 1 if missing. |
| 249 | With \\[universal-argument], insert previous kmacro-counter (but do not modify counter)." | 249 | With \\[universal-argument], insert previous kmacro-counter (but do not modify counter)." |
| 250 | (interactive "P") | 250 | (interactive "P") |
| 251 | (setq kmacro-initial-counter-value nil) | 251 | (if kmacro-initial-counter-value |
| 252 | (setq kmacro-counter kmacro-initial-counter-value | ||
| 253 | kmacro-initial-counter-value nil)) | ||
| 252 | (if (and arg (listp arg)) | 254 | (if (and arg (listp arg)) |
| 253 | (insert (format kmacro-counter-format kmacro-last-counter)) | 255 | (insert (format kmacro-counter-format kmacro-last-counter)) |
| 254 | (insert (format kmacro-counter-format kmacro-counter)) | 256 | (insert (format kmacro-counter-format kmacro-counter)) |
| @@ -275,23 +277,23 @@ With \\[universal-argument], insert previous kmacro-counter (but do not modify c | |||
| 275 | "Set kmacro-counter to ARG or prompt if missing. | 277 | "Set kmacro-counter to ARG or prompt if missing. |
| 276 | With \\[universal-argument] prefix, reset counter to its value prior to this iteration of the macro." | 278 | With \\[universal-argument] prefix, reset counter to its value prior to this iteration of the macro." |
| 277 | (interactive "NMacro counter value: ") | 279 | (interactive "NMacro counter value: ") |
| 278 | (setq kmacro-last-counter kmacro-counter | 280 | (if (not (or defining-kbd-macro executing-kbd-macro)) |
| 279 | kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) | 281 | (kmacro-display-counter (setq kmacro-initial-counter-value arg)) |
| 280 | kmacro-counter-value-start | 282 | (setq kmacro-last-counter kmacro-counter |
| 281 | arg)) | 283 | kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) |
| 282 | ;; setup initial macro counter value if we are not executing a macro. | 284 | kmacro-counter-value-start |
| 283 | (setq kmacro-initial-counter-value | 285 | arg)) |
| 284 | (and (not (or defining-kbd-macro executing-kbd-macro)) | 286 | (unless executing-kbd-macro |
| 285 | kmacro-counter)) | 287 | (kmacro-display-counter)))) |
| 286 | (unless executing-kbd-macro | ||
| 287 | (kmacro-display-counter))) | ||
| 288 | 288 | ||
| 289 | 289 | ||
| 290 | (defun kmacro-add-counter (arg) | 290 | (defun kmacro-add-counter (arg) |
| 291 | "Add numeric prefix arg (prompt if missing) to macro counter. | 291 | "Add numeric prefix arg (prompt if missing) to macro counter. |
| 292 | With \\[universal-argument], restore previous counter value." | 292 | With \\[universal-argument], restore previous counter value." |
| 293 | (interactive "NAdd to macro counter: ") | 293 | (interactive "NAdd to macro counter: ") |
| 294 | (setq kmacro-initial-counter-value nil) | 294 | (if kmacro-initial-counter-value |
| 295 | (setq kmacro-counter kmacro-initial-counter-value | ||
| 296 | kmacro-initial-counter-value nil)) | ||
| 295 | (let ((last kmacro-last-counter)) | 297 | (let ((last kmacro-last-counter)) |
| 296 | (setq kmacro-last-counter kmacro-counter | 298 | (setq kmacro-last-counter kmacro-counter |
| 297 | kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) | 299 | kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) |
| @@ -394,7 +396,10 @@ Optional arg EMPTY is message to print if no macros are defined." | |||
| 394 | (m (format-kbd-macro macro)) | 396 | (m (format-kbd-macro macro)) |
| 395 | (l (length m)) | 397 | (l (length m)) |
| 396 | (z (and nil trunc (> l x)))) | 398 | (z (and nil trunc (> l x)))) |
| 397 | (message (format "%s: %s%s" (or descr "Macro") | 399 | (message (format "%s%s: %s%s" (or descr "Macro") |
| 400 | (if (= kmacro-counter 0) "" | ||
| 401 | (format " [%s]" | ||
| 402 | (format kmacro-counter-format-start kmacro-counter))) | ||
| 398 | (if z (substring m 0 (1- x)) m) (if z "..." "")))) | 403 | (if z (substring m 0 (1- x)) m) (if z "..." "")))) |
| 399 | (message (or empty "No keyboard macros defined")))) | 404 | (message (or empty "No keyboard macros defined")))) |
| 400 | 405 | ||