* kmacro.el (kmacro-to-register): New command.

(kmacro-execute-from-register): New function.
(kmacro-keymap): Bind to 'x'.

Fixes: debbugs:14071
This commit is contained in:
Leo Liu 2013-03-29 22:53:27 +08:00
parent efc0bb7349
commit 35710234ce
2 changed files with 27 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2013-03-29 Leo Liu <sdl.web@gmail.com>
* kmacro.el (kmacro-to-register): New command.
(kmacro-execute-from-register): New function.
(kmacro-keymap): Bind to 'x'. (Bug#14071)
2013-03-29 Stefan Monnier <monnier@iro.umontreal.ca>
* mpc.el: Use defvar-local and setq-local.

View file

@ -202,6 +202,7 @@ macro to be executed before appending to it."
;; naming and binding
(define-key map "b" 'kmacro-bind-to-key)
(define-key map "n" 'kmacro-name-last-macro)
(define-key map "x" 'kmacro-to-register)
map)
"Keymap for keyboard macro commands.")
(defalias 'kmacro-keymap kmacro-keymap)
@ -836,6 +837,26 @@ Such a \"function\" cannot be called from Lisp, but it is a valid editor command
(put symbol 'kmacro t))
(defun kmacro-execute-from-register (k)
(let ((last-kbd-macro k))
(kmacro-call-macro current-prefix-arg)))
(defun kmacro-to-register (r)
"Store the last keyboard macro in register R."
(interactive
(progn
(or last-kbd-macro (error "No keyboard macro defined"))
(list (read-char "Save to register: "))))
(set-register r (registerv-make
last-kbd-macro
:jump-func 'kmacro-execute-from-register
:print-func (lambda (k)
(princ (format "a keyboard macro:\n %s"
(format-kbd-macro k))))
:insert-func (lambda (k)
(insert (format-kbd-macro k))))))
(defun kmacro-view-macro (&optional _arg)
"Display the last keyboard macro.
If repeated, it shows previous elements in the macro ring."