;; Customization:
(require 'replace)
+(require 'cl-lib)
(defgroup kmacro nil
"Simplified keyboard macro user interface."
(put symbol 'kmacro t))
-(defun kmacro-execute-from-register (k)
- (kmacro-call-macro current-prefix-arg nil nil k))
+(cl-defstruct (kmacro-register
+ (:constructor nil)
+ (:constructor kmacro-make-register (macro)))
+ macro)
+
+(cl-defmethod register-val-jump-to ((data kmacro-register) _arg)
+ (kmacro-call-macro current-prefix-arg nil nil (kmacro-register-macro data)))
+
+(cl-defmethod register-val-describe ((data kmacro-register) _verbose)
+ (princ (format "a keyboard macro:\n %s"
+ (format-kbd-macro (kmacro-register-macro data)))))
+
+(cl-defmethod register-val-insert ((data kmacro-register))
+ (insert (format-kbd-macro (kmacro-register-macro data))))
(defun kmacro-to-register (r)
"Store the last keyboard macro in register R.
(progn
(or last-kbd-macro (error "No keyboard macro defined"))
(list (register-read-with-preview "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))))))
+ (set-register r (kmacro-make-register last-kbd-macro)))
(defun kmacro-view-macro (&optional _arg)