+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.
;; 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)
(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."