diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2019-06-12 18:21:35 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2019-06-12 18:21:35 +0200 |
commit | 26f2b1faaa1dc8847f2013268c20f51c144ae711 (patch) | |
tree | ac2a36c2da794f06a5641bd928e8123b08538d96 /lisp | |
parent | 48178edeed1006775a4a6755c6ee22bf5ab7a8e4 (diff) | |
download | emacs-26f2b1faaa1dc8847f2013268c20f51c144ae711.tar.gz |
Rewrite the kmacro register function to avoid using obsolete functions
* lisp/kmacro.el (kmacro-register): New struct to replace the
general registerv struct.
(register-val-jump-to, register-val-describe)
(register-val-insert): New methods to implement the register
interface.
(kmacro-to-register): Use the kmacro-register struct.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/kmacro.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lisp/kmacro.el b/lisp/kmacro.el index 01dc0586140..e5d505662b5 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -112,6 +112,7 @@ ;; Customization: (require 'replace) +(require 'cl-lib) (defgroup kmacro nil "Simplified keyboard macro user interface." @@ -872,8 +873,20 @@ 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) - (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. @@ -883,14 +896,7 @@ Interactively, reads the register using `register-read-with-preview'." (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) |