summaryrefslogtreecommitdiff
path: root/lisp/kmacro.el
diff options
context:
space:
mode:
authorLeo Liu <sdl.web@gmail.com>2013-03-29 22:53:27 +0800
committerLeo Liu <sdl.web@gmail.com>2013-03-29 22:53:27 +0800
commit35710234cefabd10ac9bc1d3b166b5ec91b43b44 (patch)
tree4174792979b43ed6c597f5e7f676646cd6b32162 /lisp/kmacro.el
parentefc0bb734970ef30dfe6fbda151b797bcac4ae1f (diff)
downloademacs-35710234cefabd10ac9bc1d3b166b5ec91b43b44.tar.gz
* kmacro.el (kmacro-to-register): New command.
(kmacro-execute-from-register): New function. (kmacro-keymap): Bind to 'x'. Fixes: debbugs:14071
Diffstat (limited to 'lisp/kmacro.el')
-rw-r--r--lisp/kmacro.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index d573bd02397..4253fb87d5c 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -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."