94 |
;; and you can set the macro counter format with C-x C-k C-f. |
;; and you can set the macro counter format with C-x C-k C-f. |
95 |
|
|
96 |
;; The following key bindings are performed: |
;; The following key bindings are performed: |
97 |
;; |
;; |
98 |
;; Normal While defining macro |
;; Normal While defining macro |
99 |
;; --------------------------- ------------------------------ |
;; --------------------------- ------------------------------ |
100 |
;; f3 Define macro Insert current counter value |
;; f3 Define macro Insert current counter value |
102 |
;; counter value (default 0) (default increment: 1) |
;; counter value (default 0) (default increment: 1) |
103 |
;; |
;; |
104 |
;; C-u f3 APPENDs to last macro |
;; C-u f3 APPENDs to last macro |
105 |
;; |
;; |
106 |
;; f4 Call last macro End macro |
;; f4 Call last macro End macro |
107 |
;; Prefix arg specifies number |
;; Prefix arg specifies number |
108 |
;; of times to execute macro. |
;; of times to execute macro. |
109 |
;; |
;; |
110 |
;; C-u f4 Swap last and head of macro ring. |
;; C-u f4 Swap last and head of macro ring. |
111 |
;; |
;; |
112 |
;; S-mouse-3 Set point at click and End macro and execute macro at |
;; S-mouse-3 Set point at click and End macro and execute macro at |
113 |
;; execute last macro. click. |
;; execute last macro. click. |
114 |
|
|
339 |
Non-nil arg RAW means just return raw first element." |
Non-nil arg RAW means just return raw first element." |
340 |
(unless (kmacro-ring-empty-p) |
(unless (kmacro-ring-empty-p) |
341 |
(kmacro-pop-ring1 raw))) |
(kmacro-pop-ring1 raw))) |
342 |
|
|
343 |
|
|
344 |
(defun kmacro-ring-length () |
(defun kmacro-ring-length () |
345 |
"Return length of macro ring, including pseudo head." |
"Return length of macro ring, including pseudo head." |
368 |
(m (format-kbd-macro macro)) |
(m (format-kbd-macro macro)) |
369 |
(l (length m)) |
(l (length m)) |
370 |
(z (and nil trunc (> l x)))) |
(z (and nil trunc (> l x)))) |
371 |
(message (format "%s: %s%s" (or descr "Macro") |
(message (format "%s: %s%s" (or descr "Macro") |
372 |
(if z (substring m 0 (1- x)) m) (if z "..." "")))) |
(if z (substring m 0 (1- x)) m) (if z "..." "")))) |
373 |
(message (or empty "No keyboard macros defined")))) |
(message (or empty "No keyboard macros defined")))) |
374 |
|
|
439 |
(kmacro-display (car (car kmacro-ring)) "2nd macro"))) |
(kmacro-display (car (car kmacro-ring)) "2nd macro"))) |
440 |
|
|
441 |
|
|
442 |
|
|
443 |
(defun kmacro-cycle-ring-next (&optional arg) |
(defun kmacro-cycle-ring-next (&optional arg) |
444 |
"Move to next keyboard macro in keyboard macro ring. |
"Move to next keyboard macro in keyboard macro ring. |
445 |
Displays the selected macro in the echo area." |
Displays the selected macro in the echo area." |
500 |
|
|
501 |
;;; Traditional bindings: |
;;; Traditional bindings: |
502 |
|
|
503 |
|
|
504 |
;;;###autoload |
;;;###autoload |
505 |
(defun kmacro-start-macro (arg) |
(defun kmacro-start-macro (arg) |
506 |
"Record subsequent keyboard input, defining a keyboard macro. |
"Record subsequent keyboard input, defining a keyboard macro. |
527 |
(unless append |
(unless append |
528 |
(if last-kbd-macro |
(if last-kbd-macro |
529 |
(let ((len (length kmacro-ring))) |
(let ((len (length kmacro-ring))) |
530 |
(setq kmacro-ring |
(setq kmacro-ring |
531 |
(cons |
(cons |
532 |
(list last-kbd-macro kmacro-counter kmacro-counter-format-start) |
(list last-kbd-macro kmacro-counter kmacro-counter-format-start) |
533 |
kmacro-ring)) |
kmacro-ring)) |
538 |
kmacro-last-counter kmacro-counter |
kmacro-last-counter kmacro-counter |
539 |
kmacro-counter-format-start kmacro-counter-format)) |
kmacro-counter-format-start kmacro-counter-format)) |
540 |
|
|
541 |
(start-kbd-macro append |
(start-kbd-macro append |
542 |
(and append |
(and append |
543 |
(if kmacro-execute-before-append |
(if kmacro-execute-before-append |
544 |
(> (car arg) 4) |
(> (car arg) 4) |
592 |
kmacro-call-repeat-key))) |
kmacro-call-repeat-key))) |
593 |
(setq repeat-key-str (format-kbd-macro (vector repeat-key) nil)) |
(setq repeat-key-str (format-kbd-macro (vector repeat-key) nil)) |
594 |
(while repeat-key |
(while repeat-key |
595 |
(message "(Type %s to repeat macro%s)" |
(message "(Type %s to repeat macro%s)" |
596 |
repeat-key-str |
repeat-key-str |
597 |
(if (and kmacro-call-repeat-with-arg |
(if (and kmacro-call-repeat-with-arg |
598 |
arg (> arg 1)) |
arg (> arg 1)) |
640 |
With numeric prefix ARG, repeat macro that many times. |
With numeric prefix ARG, repeat macro that many times. |
641 |
With \\[universal-argument], call second macro in macro ring." |
With \\[universal-argument], call second macro in macro ring." |
642 |
(interactive "P") |
(interactive "P") |
643 |
(cond |
(cond |
644 |
(defining-kbd-macro |
(defining-kbd-macro |
645 |
(if kmacro-call-repeat-key |
(if kmacro-call-repeat-key |
646 |
(kmacro-call-macro arg no-repeat t) |
(kmacro-call-macro arg no-repeat t) |
796 |
(format "Macro: %s%s%s%s%s\n" |
(format "Macro: %s%s%s%s%s\n" |
797 |
(format-kbd-macro kmacro-step-edit-new-macro 1) |
(format-kbd-macro kmacro-step-edit-new-macro 1) |
798 |
(if (and kmacro-step-edit-new-macro (> (length kmacro-step-edit-new-macro) 0)) " " "") |
(if (and kmacro-step-edit-new-macro (> (length kmacro-step-edit-new-macro) 0)) " " "") |
799 |
(propertize (if keys (format-kbd-macro keys) |
(propertize (if keys (format-kbd-macro keys) |
800 |
(if kmacro-step-edit-appending "<APPEND>" "<INSERT>")) 'face 'region) |
(if kmacro-step-edit-appending "<APPEND>" "<INSERT>")) 'face 'region) |
801 |
(if future " " "") |
(if future " " "") |
802 |
(if future (format-kbd-macro future) "")) |
(if future (format-kbd-macro future) "")) |
813 |
curmsg)) |
curmsg)) |
814 |
(t "")) |
(t "")) |
815 |
(if keys |
(if keys |
816 |
(format "%s\n%s%s %S [yn iIaArR C-k kq!] " |
(format "%s\n%s%s %S [yn iIaArR C-k kq!] " |
817 |
(propertize "\ |
(propertize "\ |
818 |
--------------Step Edit Keyboard Macro [?: help]---------------" 'face 'mode-line) |
--------------Step Edit Keyboard Macro [?: help]---------------" 'face 'mode-line) |
819 |
(if kmacro-step-edit-help "\ |
(if kmacro-step-edit-help "\ |
826 |
" "") |
" "") |
827 |
(propertize "Next command:" 'face 'bold) |
(propertize "Next command:" 'face 'bold) |
828 |
this-command) |
this-command) |
829 |
(propertize |
(propertize |
830 |
(format "Type key sequence%s to insert and execute%s: " |
(format "Type key sequence%s to insert and execute%s: " |
831 |
(if (numberp kmacro-step-edit-inserting) "" "s") |
(if (numberp kmacro-step-edit-inserting) "" "s") |
832 |
(if (numberp kmacro-step-edit-inserting) "" " (end with C-j)")) |
(if (numberp kmacro-step-edit-inserting) "" " (end with C-j)")) |
864 |
(clear-this-command-keys) ;; recent-keys actually |
(clear-this-command-keys) ;; recent-keys actually |
865 |
(let (unread-command-events) |
(let (unread-command-events) |
866 |
(quoted-insert (prefix-numeric-value current-prefix-arg)) |
(quoted-insert (prefix-numeric-value current-prefix-arg)) |
867 |
(setq kmacro-step-edit-new-macro |
(setq kmacro-step-edit-new-macro |
868 |
(vconcat kmacro-step-edit-new-macro (recent-keys))) |
(vconcat kmacro-step-edit-new-macro (recent-keys))) |
869 |
(when unread-command-events |
(when unread-command-events |
870 |
(setq kmacro-step-edit-new-macro |
(setq kmacro-step-edit-new-macro |
957 |
(if (> executing-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) |
(if (> executing-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) |
958 |
(setq kmacro-step-edit-new-macro |
(setq kmacro-step-edit-new-macro |
959 |
(vconcat kmacro-step-edit-new-macro |
(vconcat kmacro-step-edit-new-macro |
960 |
(substring executing-kbd-macro |
(substring executing-kbd-macro |
961 |
(or kmacro-step-edit-prefix-index kmacro-step-edit-key-index) |
(or kmacro-step-edit-prefix-index kmacro-step-edit-key-index) |
962 |
(if (eq act t) nil executing-macro-index))) |
(if (eq act t) nil executing-macro-index))) |
963 |
kmacro-step-edit-prefix-index nil)) |
kmacro-step-edit-prefix-index nil)) |
1068 |
(add-hook 'pre-command-hook 'kmacro-step-edit-pre-command nil nil) |
(add-hook 'pre-command-hook 'kmacro-step-edit-pre-command nil nil) |
1069 |
(if kmacro-step-edit-key-index |
(if kmacro-step-edit-key-index |
1070 |
(setq executing-macro-index kmacro-step-edit-key-index) |
(setq executing-macro-index kmacro-step-edit-key-index) |
1071 |
(setq kmacro-step-edit-key-index executing-macro-index)))) |
(setq kmacro-step-edit-key-index executing-macro-index)))) |
1072 |
|
|
1073 |
|
|
1074 |
(defun kmacro-step-edit-macro () |
(defun kmacro-step-edit-macro () |