]> git.eshelyaron.com Git - emacs.git/commit
kmacro.el: Unify the lambda and the list representations
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 28 Dec 2021 17:03:44 +0000 (12:03 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 28 Dec 2021 17:03:44 +0000 (12:03 -0500)
commita69d03779c7736db1c7d78fd62a1c1aa01a9dc8b
tree66a96962390611cb3ddcc762cfea01e471270278
parent9f33a163d3cdf5194f82505f050ee2efaa04d2f6
kmacro.el: Unify the lambda and the list representations

Kmacros used to be represented as a triplet (MAC COUNTER FORMAT),
and then wrapped into a lambda to turn them into commands.
Replace the triplet with an FCR so it's directly executable.
Take advantage of the change to promote the key-description
format where applicable.

* lisp/kmacro.el (kmacro): New FCR type, to replace both `kmacro-function`
and the (MAC COUNTER FORMAT) representation of kmacros.
(kmacro-p): Adjust.
(kmacro-ring-head): Use `kmacro` constructor.
(kmacro-push-ring): Add backward compatibility code for old
list representation.
(kmacro-view-ring-2nd, kmacro-start-macro, kmacro-view-macro):
(kmacro-split-ring-element): Adjust to new representation.
(kmacro-exec-ring-item): Redefine as obsolete alias.
(kmacro-call-ring-2nd, kmacro-end-or-call-macro): Simplify accordingly.
(kmacro-function): Delete FCR type.
(kmacro): Rename from `kmacro-lambda-form` and streamline
calling convention.  Use `execute-kbd-macro` rather than
`kmacro-exec-ring-item`.
(kmacro-lambda-form, kmacro-extract-lambda): Rewrite and mark as obsolete.
(cl-print-object): Use the key-description format and skip the
counter and format parts if they're trivial.
(kmacro-bind-to-key, kmacro-name-last-macro): Simplify.

* test/lisp/kmacro-tests.el (kmacro-tests-kmacro-bind-to-single-key):
Suppress obsoletion warning.
(kmacro-tests-name-last-macro-bind-and-rebind): Tighten the check
a tiny bit.
(kmacro-tests--cl-print): Adjust to the new key-description output.

* lisp/macros.el (macro--string-to-vector): New function.
(insert-kbd-macro): Use it, and change the generated code to use
`kmacro` and the key-description format.

* lisp/edmacro.el (edit-kbd-macro): Adjust to new representation.
(edmacro-finish-edit): Use `kmacro` constructor.
lisp/edmacro.el
lisp/emacs-lisp/fcr.el
lisp/kmacro.el
lisp/macros.el
test/lisp/kmacro-tests.el