From: Lars Ingebrigtsen Date: Wed, 12 Jun 2019 16:21:35 +0000 (+0200) Subject: Rewrite the kmacro register function to avoid using obsolete functions X-Git-Tag: emacs-27.0.90~2605 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=26f2b1faaa1dc8847f2013268c20f51c144ae711;p=emacs.git 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. --- 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)