Commit 26f2b1fa authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

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.
parent 48178ede
Pipeline #2010 failed with stage
in 4 seconds
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment