aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2002-08-29 13:06:26 +0000
committerKim F. Storm2002-08-29 13:06:26 +0000
commitc8bf445eb519f487c5bc578cd1b9fa61ad7be967 (patch)
treec65b389df0a372bb40b82fea442a2cecc5832125
parent2c6d37264cb31fc1ef27a597311eb3c790ccf098 (diff)
downloademacs-c8bf445eb519f487c5bc578cd1b9fa61ad7be967.tar.gz
emacs-c8bf445eb519f487c5bc578cd1b9fa61ad7be967.zip
Changed default bindings from F7/F8 to F3/F4.
Changed default binding of C-x e to kmacro-end-or-call-macro. (kmacro-call-repeat-key, kmacro-call-repeat-with-arg): New custom variables. (kmacro-get-prefix-arg): New function. (kmacro-repeat-on-last-key): Renamed from kmacro-repeat-loop and improved. Callers changed. (kmacro-call-macro): Repeat macro by repeating last key or key defined in kmacro-call-repeat-key. New third arg non-nil means to end current macro. (kmacro-end-or-call-macro): Call kmacro-call-macro appropriately to get repeat last key functionality. (kmacro-start-macro-or-insert-counter): Improve doc string.
-rw-r--r--lisp/kmacro.el259
1 files changed, 165 insertions, 94 deletions
diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index b44f4f71a50..53324f2b1f9 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -30,26 +30,26 @@
30;; type to be really useful for doing small repeated tasks. 30;; type to be really useful for doing small repeated tasks.
31 31
32;; With kmacro, two function keys are dedicated to keyboard macros, 32;; With kmacro, two function keys are dedicated to keyboard macros,
33;; by default F7 and F8. Personally, I prefer F1 and F2, but those 33;; by default F3 and F4. Personally, I prefer F1 and F2, but those
34;; keys already have default bindings. 34;; keys already have default bindings.
35;; 35;;
36;; To start defining a keyboard macro, use F7. To end the macro, 36;; To start defining a keyboard macro, use F3. To end the macro,
37;; use F8, and to call the macro also use F8. This makes it very 37;; use F4, and to call the macro also use F4. This makes it very
38;; easy to repeat a macro immediately after defining it. 38;; easy to repeat a macro immediately after defining it.
39;; 39;;
40;; You can call the macro repeatedly by pressing F8 multiple times, or 40;; You can call the macro repeatedly by pressing F4 multiple times, or
41;; you can give a numeric prefix argument specifying the number of 41;; you can give a numeric prefix argument specifying the number of
42;; times to repeat the macro. Macro execution automatically 42;; times to repeat the macro. Macro execution automatically
43;; terminates when point reaches the end of the buffer or if an error 43;; terminates when point reaches the end of the buffer or if an error
44;; is signalled by ringing the bell. 44;; is signalled by ringing the bell.
45 45
46;; When you define a macro with F7/F8, it is automatically added to 46;; When you define a macro with F3/F4, it is automatically added to
47;; the head of the "keyboard macro ring", and F8 actually executes the 47;; the head of the "keyboard macro ring", and F4 actually executes the
48;; first element of the macro ring. 48;; first element of the macro ring.
49;; 49;;
50;; Note: an empty macro is never added to the macro ring. 50;; Note: an empty macro is never added to the macro ring.
51;; 51;;
52;; You can execute the second element on the macro ring with C-u F8 or 52;; You can execute the second element on the macro ring with C-u F4 or
53;; C-x C-k C-l, you can use C-x C-k C-p and C-x C-k C-n to cycle 53;; C-x C-k C-l, you can use C-x C-k C-p and C-x C-k C-n to cycle
54;; through the macro ring, and you can swap the first and second 54;; through the macro ring, and you can swap the first and second
55;; elements with C-x C-k C-t. To delete the first element in the 55;; elements with C-x C-k C-t. To delete the first element in the
@@ -66,21 +66,21 @@
66;; the head macro with C-d, or edit the current macro with C-e without 66;; the head macro with C-d, or edit the current macro with C-e without
67;; repeating the C-x C-k prefix. 67;; repeating the C-x C-k prefix.
68 68
69;; If you enter F7 while defining the macro, the numeric value of 69;; If you enter F3 while defining the macro, the numeric value of
70;; `kmacro-counter' is inserted using the `kmacro-counter-format', and 70;; `kmacro-counter' is inserted using the `kmacro-counter-format', and
71;; `kmacro-counter' is incremented by 1 (or the numeric prefix value 71;; `kmacro-counter' is incremented by 1 (or the numeric prefix value
72;; of F7). 72;; of F3).
73;; 73;;
74;; The initial value of `kmacro-counter' is 0, or the numeric prefix 74;; The initial value of `kmacro-counter' is 0, or the numeric prefix
75;; value given to F7 when starting the macro. 75;; value given to F3 when starting the macro.
76;; 76;;
77;; Now, each time you call the macro using F8, the current 77;; Now, each time you call the macro using F4, the current
78;; value of `kmacro-counter' is inserted and incremented, making it 78;; value of `kmacro-counter' is inserted and incremented, making it
79;; easy to insert incremental numbers in the buffer. 79;; easy to insert incremental numbers in the buffer.
80;; 80;;
81;; Example: 81;; Example:
82;; 82;;
83;; The following sequence: M-5 F7 x M-2 F7 y F8 F8 F8 F8 83;; The following sequence: M-5 F3 x M-2 F3 y F4 F4 F4 F4
84;; inserts the following string: x5yx7yx9yx11y 84;; inserts the following string: x5yx7yx9yx11y
85 85
86;; A macro can also be called using a mouse click, default S-mouse-3. 86;; A macro can also be called using a mouse click, default S-mouse-3.
@@ -88,7 +88,7 @@
88 88
89;; You can edit the last macro using C-x C-k C-e. 89;; You can edit the last macro using C-x C-k C-e.
90 90
91;; You can append to the last macro using C-u F7. 91;; You can append to the last macro using C-u F3.
92 92
93;; You can set the macro counter using C-x C-k C-c, add to it using C-x C-k C-a, 93;; You can set the macro counter using C-x C-k C-c, add to it using C-x C-k C-a,
94;; and you can set the macro counter format with C-x C-k C-f. 94;; and you can set the macro counter format with C-x C-k C-f.
@@ -97,17 +97,17 @@
97;; 97;;
98;; Normal While defining macro 98;; Normal While defining macro
99;; --------------------------- ------------------------------ 99;; --------------------------- ------------------------------
100;; f7 Define macro Insert current counter value 100;; f3 Define macro Insert current counter value
101;; Prefix arg specifies initial and increase counter by prefix 101;; Prefix arg specifies initial and increase counter by prefix
102;; counter value (default 0) (default increment: 1) 102;; counter value (default 0) (default increment: 1)
103;; 103;;
104;; C-u f7 APPENDs to last macro 104;; C-u f3 APPENDs to last macro
105;; 105;;
106;; f8 Call last macro End macro 106;; f4 Call last macro End macro
107;; Prefix arg specifies number 107;; Prefix arg specifies number
108;; of times to execute macro. 108;; of times to execute macro.
109;; 109;;
110;; C-u f8 Swap last and head of macro ring. 110;; C-u f4 Swap last and head of macro ring.
111;; 111;;
112;; S-mouse-3 Set point at click and End macro and execute macro at 112;; S-mouse-3 Set point at click and End macro and execute macro at
113;; execute last macro. click. 113;; execute last macro. click.
@@ -152,20 +152,33 @@ macro to be executed before appending to it."
152 :type 'boolean 152 :type 'boolean
153 :group 'kmacro) 153 :group 'kmacro)
154 154
155(defcustom kmacro-call-repeat-key t
156 "Allow repeating macro call using last key or a specific key."
157 :type '(choice (const :tag "Disabled" nil)
158 (const :tag "Last key" t)
159 (character :tag "Character" :value ?e)
160 (symbol :tag "Key symbol" :value RET))
161 :group 'kmacro)
162
163(defcustom kmacro-call-repeat-with-arg nil
164 "Repeat macro call with original arg when non-nil; repeat once if nil."
165 :type 'boolean
166 :group 'kmacro)
167
155 168
156;; Keymap 169;; Keymap
157 170
158(defvar kmacro-keymap 171(defvar kmacro-keymap
159 (let ((map (make-sparse-keymap))) 172 (let ((map (make-sparse-keymap)))
160 (define-key map "\C-s" 'kmacro-start-macro) 173 (define-key map "\C-s" 'kmacro-start-macro)
161 (define-key map "\C-k" 'kmacro-end-or-call-macro-rep) 174 (define-key map "\C-k" 'kmacro-end-or-call-macro-repeat)
162 (define-key map "\C-e" 'kmacro-edit-macro) 175 (define-key map "\C-e" 'kmacro-edit-macro-repeat)
163 (define-key map "\r" 'kmacro-edit-macro-nr) 176 (define-key map "\r" 'kmacro-edit-macro)
164 (define-key map "l" 'kmacro-edit-lossage) 177 (define-key map "l" 'kmacro-edit-lossage)
165 (define-key map "\C-i" 'kmacro-insert-counter) 178 (define-key map "\C-i" 'kmacro-insert-counter)
166 (define-key map "\C-a" 'kmacro-add-counter) 179 (define-key map "\C-a" 'kmacro-add-counter)
167 (define-key map "\C-v" 'kmacro-view-macro-rep) 180 (define-key map "\C-v" 'kmacro-view-macro-repeat)
168 (define-key map "\C-l" 'kmacro-call-ring-2nd-rep) 181 (define-key map "\C-l" 'kmacro-call-ring-2nd-repeat)
169 (define-key map "\C-r" 'kmacro-view-ring-2nd) 182 (define-key map "\C-r" 'kmacro-view-ring-2nd)
170 (define-key map "\C-n" 'kmacro-cycle-ring-next) 183 (define-key map "\C-n" 'kmacro-cycle-ring-next)
171 (define-key map "\C-p" 'kmacro-cycle-ring-previous) 184 (define-key map "\C-p" 'kmacro-cycle-ring-previous)
@@ -186,9 +199,9 @@ macro to be executed before appending to it."
186;;; Provide some binding for startup: 199;;; Provide some binding for startup:
187;;;###autoload (global-set-key "\C-x(" 'kmacro-start-macro) 200;;;###autoload (global-set-key "\C-x(" 'kmacro-start-macro)
188;;;###autoload (global-set-key "\C-x)" 'kmacro-end-macro) 201;;;###autoload (global-set-key "\C-x)" 'kmacro-end-macro)
189;;;###autoload (global-set-key "\C-xe" 'kmacro-call-macro) 202;;;###autoload (global-set-key "\C-xe" 'kmacro-end-or-call-macro)
190;;;###autoload (global-set-key [f7] 'kmacro-start-macro-or-insert-counter) 203;;;###autoload (global-set-key [f3] 'kmacro-start-macro-or-insert-counter)
191;;;###autoload (global-set-key [f8] 'kmacro-end-or-call-macro) 204;;;###autoload (global-set-key [f4] 'kmacro-end-or-call-macro)
192;;;###autoload (global-set-key "\C-x\C-k" 'kmacro-keymap) 205;;;###autoload (global-set-key "\C-x\C-k" 'kmacro-keymap)
193;;;###autoload (autoload 'kmacro-keymap "kmacro" "Keymap for keyboard macro commands." t 'keymap) 206;;;###autoload (autoload 'kmacro-keymap "kmacro" "Keymap for keyboard macro commands." t 'keymap)
194 207
@@ -355,6 +368,43 @@ Check only `last-kbd-macro' if optional arg NONE is non-nil."
355 (message (or empty "No keyboard macros defined")))) 368 (message (or empty "No keyboard macros defined"))))
356 369
357 370
371(defun kmacro-repeat-on-last-key (keys)
372 "Process kmacro commands keys immidiately after cycling the ring."
373 (setq keys (vconcat keys))
374 (let ((n (1- (length keys)))
375 cmd done repeat)
376 (while (and last-kbd-macro
377 (not done)
378 (aset keys n (read-event))
379 (setq cmd (key-binding keys t))
380 (setq repeat (get cmd 'kmacro-repeat)))
381 (clear-this-command-keys t)
382 (cond
383 ((eq repeat 'ring)
384 (if kmacro-ring
385 (let ((kmacro-repeat-no-prefix nil))
386 (funcall cmd nil))
387 (kmacro-display last-kbd-macro t)))
388 ((eq repeat 'head)
389 (let ((kmacro-repeat-no-prefix nil))
390 (funcall cmd nil)))
391 ((eq repeat 'stop)
392 (funcall cmd nil)
393 (setq done t)))
394 (setq last-input-event nil)))
395 (when last-input-event
396 (clear-this-command-keys t)
397 (setq unread-command-events (list last-input-event))))
398
399
400(defun kmacro-get-repeat-prefix ()
401 (let (keys)
402 (and kmacro-repeat-no-prefix
403 (setq keys (this-single-command-keys))
404 (> (length keys) 1)
405 keys)))
406
407
358(defun kmacro-call-ring-2nd (arg) 408(defun kmacro-call-ring-2nd (arg)
359 "Execute second keyboard macro at in macro ring." 409 "Execute second keyboard macro at in macro ring."
360 (interactive "P") 410 (interactive "P")
@@ -366,14 +416,15 @@ Check only `last-kbd-macro' if optional arg NONE is non-nil."
366 (setcar (cdr (car kmacro-ring)) kmacro-counter)))) 416 (setcar (cdr (car kmacro-ring)) kmacro-counter))))
367 417
368 418
369(defun kmacro-call-ring-2nd-rep (arg) 419(defun kmacro-call-ring-2nd-repeat (arg)
370 "Like `kmacro-call-ring-2nd', but allow repeat without kmacro prefix." 420 "Like `kmacro-call-ring-2nd', but allow repeat without repeating prefix."
371 (interactive "P") 421 (interactive "P")
372 (kmacro-call-ring-2nd arg) 422 (let ((keys (kmacro-get-repeat-prefix)))
373 (if kmacro-ring 423 (kmacro-call-ring-2nd arg)
374 (kmacro-repeat-loop))) 424 (if (and kmacro-ring keys)
425 (kmacro-repeat-on-last-key keys))))
375 426
376(put 'kmacro-call-ring-2nd-rep 'kmacro-repeat 'head) 427(put 'kmacro-call-ring-2nd-repeat 'kmacro-repeat 'head)
377 428
378 429
379(defun kmacro-view-ring-2nd () 430(defun kmacro-view-ring-2nd ()
@@ -383,31 +434,6 @@ Check only `last-kbd-macro' if optional arg NONE is non-nil."
383 (kmacro-display (car (car kmacro-ring)) "2nd macro"))) 434 (kmacro-display (car (car kmacro-ring)) "2nd macro")))
384 435
385 436
386(defun kmacro-repeat-loop ()
387 "Process kmacro commands keys immidiately after cycling the ring."
388 (when kmacro-repeat-no-prefix
389 (let (cmd done repeat)
390 (while (and last-kbd-macro
391 (not done)
392 (setq cmd (lookup-key kmacro-keymap (vector (read-event))))
393 (setq repeat (get cmd 'kmacro-repeat)))
394 (clear-this-command-keys t)
395 (cond
396 ((eq repeat 'ring)
397 (if kmacro-ring
398 (let ((kmacro-repeat-no-prefix nil))
399 (funcall cmd nil))
400 (kmacro-display last-kbd-macro t)))
401 ((eq repeat 'head)
402 (funcall cmd nil))
403 ((eq repeat 'stop)
404 (funcall cmd nil)
405 (setq done t)))
406 (setq last-input-event nil)))
407 (when last-input-event
408 (clear-this-command-keys t)
409 (setq unread-command-events (list last-input-event)))))
410
411 437
412(defun kmacro-cycle-ring-next (&optional arg) 438(defun kmacro-cycle-ring-next (&optional arg)
413 "Move to next keyboard macro in keyboard macro ring. 439 "Move to next keyboard macro in keyboard macro ring.
@@ -415,13 +441,15 @@ Displays the selected macro in the echo area."
415 (interactive) 441 (interactive)
416 (unless (kmacro-ring-empty-p) 442 (unless (kmacro-ring-empty-p)
417 (kmacro-push-ring) 443 (kmacro-push-ring)
418 (let* ((len (length kmacro-ring)) 444 (let* ((keys (kmacro-get-repeat-prefix))
445 (len (length kmacro-ring))
419 (tail (nthcdr (- len 2) kmacro-ring)) 446 (tail (nthcdr (- len 2) kmacro-ring))
420 (elt (car (cdr tail)))) 447 (elt (car (cdr tail))))
421 (setcdr tail nil) 448 (setcdr tail nil)
422 (kmacro-split-ring-element elt)) 449 (kmacro-split-ring-element elt)
423 (kmacro-display last-kbd-macro t) 450 (kmacro-display last-kbd-macro t)
424 (kmacro-repeat-loop))) 451 (if keys
452 (kmacro-repeat-on-last-key keys)))))
425 453
426(put 'kmacro-cycle-ring-next 'kmacro-repeat 'ring) 454(put 'kmacro-cycle-ring-next 'kmacro-repeat 'ring)
427 455
@@ -431,13 +459,15 @@ Displays the selected macro in the echo area."
431Displays the selected macro in the echo area." 459Displays the selected macro in the echo area."
432 (interactive) 460 (interactive)
433 (unless (kmacro-ring-empty-p) 461 (unless (kmacro-ring-empty-p)
434 (let ((cur (kmacro-ring-head))) 462 (let ((keys (kmacro-get-repeat-prefix))
463 (cur (kmacro-ring-head)))
435 (kmacro-pop-ring1) 464 (kmacro-pop-ring1)
436 (if kmacro-ring 465 (if kmacro-ring
437 (nconc kmacro-ring (list cur)) 466 (nconc kmacro-ring (list cur))
438 (setq kmacro-ring (list cur)))) 467 (setq kmacro-ring (list cur)))
439 (kmacro-display last-kbd-macro t) 468 (kmacro-display last-kbd-macro t)
440 (kmacro-repeat-loop))) 469 (if keys
470 (kmacro-repeat-on-last-key keys)))))
441 471
442(put 'kmacro-cycle-ring-previous 'kmacro-repeat 'ring) 472(put 'kmacro-cycle-ring-previous 'kmacro-repeat 'ring)
443 473
@@ -529,28 +559,63 @@ An argument of zero means repeat until error."
529 559
530 560
531;;;###autoload 561;;;###autoload
532(defun kmacro-call-macro (arg) 562(defun kmacro-call-macro (arg &optional no-repeat end-macro)
533 "Call the last keyboard macro that you defined with \\[kmacro-start-macro]. 563 "Call the last keyboard macro that you defined with \\[kmacro-start-macro].
534
535A prefix argument serves as a repeat count. Zero means repeat until error. 564A prefix argument serves as a repeat count. Zero means repeat until error.
536 565
537To make a macro permanent so you can call it even after 566When you call the macro, you can call the macro again by repeating
538defining others, use M-x name-last-kbd-macro." 567just the last key in the key sequence that you used to call this
539 (interactive "p") 568command. See `kmacro-call-repeat-key' and `kmacro-call-repeat-with-arg'
540 (call-last-kbd-macro arg #'kmacro-loop-setup-function)) 569for details on how to adjust or disable this behaviour.
541 570
571To make a macro permanent so you can call it even after defining
572others, use M-x name-last-kbd-macro."
573 (interactive "p")
574 (let ((repeat-key (and (null no-repeat)
575 (> (length (this-single-command-keys)) 1)
576 last-input-event))
577 repeat-key-str)
578 (if end-macro
579 (kmacro-end-macro arg)
580 (call-last-kbd-macro arg #'kmacro-loop-setup-function))
581 (when (and (or (null arg) (> arg 0))
582 (setq repeat-key
583 (if (eq kmacro-call-repeat-key t) repeat-key kmacro-call-repeat-key)))
584 (require 'edmacro)
585 (setq repeat-key-str (edmacro-format-keys (vector repeat-key) nil))
586 (while repeat-key
587 (message "Repeat macro %swith `%s'..."
588 (if (and kmacro-call-repeat-with-arg
589 arg (> arg 1))
590 (format "%d times " arg) "")
591 repeat-key-str)
592 (if (equal repeat-key (read-event))
593 (progn
594 (clear-this-command-keys t)
595 (call-last-kbd-macro (and kmacro-call-repeat-with-arg arg) #'kmacro-loop-setup-function)
596 (setq last-input-event nil))
597 (setq repeat-key nil)))
598 (when last-input-event
599 (clear-this-command-keys t)
600 (setq unread-command-events (list last-input-event))))))
542 601
543 602
544;;; Combined function key bindings: 603;;; Combined function key bindings:
545 604
546;;;###autoload 605;;;###autoload
547(defun kmacro-start-macro-or-insert-counter (arg) 606(defun kmacro-start-macro-or-insert-counter (arg)
548 "Set `kmacro-counter' to ARG or 0 if missing, and `start-kbd-macro'. 607 "Record subsequent keyboard input, defining a keyboard macro.
549With \\[universal-argument], append to current keyboard macro (keep kmacro-counter). 608The commands are recorded even as they are executed.
550 609
551When defining/executing macro, insert macro counter and increment with 610Sets the `kmacro-counter' to ARG (or 0 if no prefix arg) before defining the
552ARG or 1 if missing. 611macro.
553With \\[universal-argument], insert previous kmacro-counter (but do not modify counter). 612
613With \\[universal-argument], appends to current keyboard macro (keeping
614the current value of `kmacro-counter').
615
616When defining/executing macro, inserts macro counter and increments
617the counter with ARG or 1 if missing. With \\[universal-argument],
618inserts previous kmacro-counter (but do not modify counter).
554 619
555The macro counter can be modified via \\[kmacro-set-counter] and \\[kmacro-add-counter]. 620The macro counter can be modified via \\[kmacro-set-counter] and \\[kmacro-add-counter].
556The format of the counter can be modified via \\[kmacro-set-format]." 621The format of the counter can be modified via \\[kmacro-set-format]."
@@ -561,27 +626,31 @@ The format of the counter can be modified via \\[kmacro-set-format]."
561 626
562 627
563;;;###autoload 628;;;###autoload
564(defun kmacro-end-or-call-macro (arg) 629(defun kmacro-end-or-call-macro (arg &optional no-repeat)
565 "End kbd macro if currently being defined; else call last kbd macro. 630 "End kbd macro if currently being defined; else call last kbd macro.
566With numeric prefix ARG, repeat macro that many times. 631With numeric prefix ARG, repeat macro that many times.
567With \\[universal-argument], call second macro in macro ring." 632With \\[universal-argument], call second macro in macro ring."
568 (interactive "P") 633 (interactive "P")
569 (cond 634 (cond
570 (defining-kbd-macro 635 (defining-kbd-macro
571 (kmacro-end-macro arg)) 636 (if kmacro-call-repeat-key
637 (kmacro-call-macro arg no-repeat t)
638 (kmacro-end-macro arg)))
572 ((and arg (listp arg)) 639 ((and arg (listp arg))
573 (kmacro-call-ring-2nd 1)) 640 (kmacro-call-ring-2nd 1))
574 (t 641 (t
575 (kmacro-call-macro arg)))) 642 (kmacro-call-macro arg no-repeat))))
576 643
577 644
578(defun kmacro-end-or-call-macro-rep (arg) 645(defun kmacro-end-or-call-macro-repeat (arg)
579 "As `kmacro-end-or-call-macro' but allows repeat without kmacro prefix." 646 "As `kmacro-end-or-call-macro' but allows repeat without repeating prefix."
580 (interactive "P") 647 (interactive "P")
581 (kmacro-end-or-call-macro arg) 648 (let ((keys (kmacro-get-repeat-prefix)))
582 (kmacro-repeat-loop)) 649 (kmacro-end-or-call-macro arg t)
650 (if keys
651 (kmacro-repeat-on-last-key keys))))
583 652
584(put 'kmacro-end-or-call-macro-rep 'kmacro-repeat 'head) 653(put 'kmacro-end-or-call-macro-repeat 'kmacro-repeat 'head)
585 654
586 655
587;;;###autoload 656;;;###autoload
@@ -592,7 +661,7 @@ If kbd macro currently being defined end it before activating it."
592 (when defining-kbd-macro 661 (when defining-kbd-macro
593 (end-kbd-macro)) 662 (end-kbd-macro))
594 (mouse-set-point event) 663 (mouse-set-point event)
595 (kmacro-call-macro nil)) 664 (kmacro-call-macro nil t))
596 665
597 666
598;;; Misc. commands 667;;; Misc. commands
@@ -616,27 +685,29 @@ If kbd macro currently being defined end it before activating it."
616 (kmacro-display last-kbd-macro)) 685 (kmacro-display last-kbd-macro))
617 686
618 687
619(defun kmacro-view-macro-rep (&optional arg) 688(defun kmacro-view-macro-repeat (&optional arg)
620 "Like `kmacro-view-macro', but allow repeat without kmacro prefix." 689 "Like `kmacro-view-macro', but allow repeat without repeating prefix."
621 (interactive) 690 (interactive)
622 (kmacro-view-macro arg) 691 (let ((keys (kmacro-get-repeat-prefix)))
623 (if last-kbd-macro 692 (kmacro-view-macro arg)
624 (kmacro-repeat-loop))) 693 (if (and last-kbd-macro keys)
694 (kmacro-repeat-on-last-key keys))))
625 695
626(put 'kmacro-view-macro-rep 'kmacro-repeat 'head) 696(put 'kmacro-view-macro-repeat 'kmacro-repeat 'head)
627 697
628(defun kmacro-edit-macro (&optional arg) 698
699(defun kmacro-edit-macro-repeat (&optional arg)
629 "Edit last keyboard macro." 700 "Edit last keyboard macro."
630 (interactive "P") 701 (interactive "P")
631 (edit-kbd-macro "\r" arg)) 702 (edit-kbd-macro "\r" arg))
632 703
633(put 'kmacro-edit-macro 'kmacro-repeat 'stop) 704(put 'kmacro-edit-macro-repeat 'kmacro-repeat 'stop)
634 705
635 706
636(defun kmacro-edit-macro-nr (&optional arg) 707(defun kmacro-edit-macro (&optional arg)
637 "As edit last keyboard macro, but without kmacro-repeat property." 708 "As edit last keyboard macro, but without kmacro-repeat property."
638 (interactive "P") 709 (interactive "P")
639 (kmacro-edit-macro arg)) 710 (edit-kbd-macro "\r" arg))
640 711
641 712
642(defun kmacro-edit-lossage () 713(defun kmacro-edit-lossage ()