]> git.eshelyaron.com Git - emacs.git/commit
kmacro: Represent it as an OClosure
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 2 Apr 2022 00:07:33 +0000 (20:07 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 2 Apr 2022 00:07:33 +0000 (20:07 -0400)
commitc75f65442ddfd2427d95278c44214c0cf1d5a2ee
tree2f8c0d01cca64216d8592e1e0d0522c8ccc97c82
parenta15f9d4e58223c6b40b0522e2f2921830b136894
kmacro: Represent it as an OClosure

Merge the old lambda+list into a single OClosure object which plays
both roles at the same time.  Take advantage of it to provide a
`cl-print-object` method so kmacro objects print nicely using the
`key-parse` syntax.
Also replace the old `kmacro-lambda-form` with a new `kmacro` constructor
which takes a `key-parse` syntax, so that the code inserted with
`insert-kbd-macro` is now more readable.

* lisp/kmacro.el (kmacro): New OClosure type.
(kmacro-ring-head): Use `kmacro` constructor.
(kmacro-push-ring): Convert `elt` from old representation if needed.
(kmacro-split-ring-element, kmacro-view-ring-2nd, kmacro-view-macro):
Adapt to new representation.
(kmacro-exec-ring-item): Turn into obsolete alias.
(kmacro-call-ring-2nd, kmacro-end-or-call-macro): Adjust accordingly.
(kmacro-start-macro): Simplify call to `kmacro-push-ring`.
(kmacro): New constructor function.  Replaces `kmacro-lambda-form`.
(kmacro-lambda-form): Use it and declare obsolete.
(kmacro-extract-lambda): Rewrite and declare obsolete.
(kmacro-p): Rewrite.
(cl-print-object): New method.
(kmacro-bind-to-key, kmacro-name-last-macro): Simplify.

* lisp/macros.el (macro--string-to-vector): New function.
(insert-kbd-macro): Use it.  Generate code using the `kmacro` constructor.

* test/lisp/kmacro-tests.el (kmacro-tests-kmacro-bind-to-single-key):
Silence warning.
(kmacro-tests-name-last-macro-bind-and-rebind): Strengthen the test a bit.
(kmacro-tests--cl-print): New test.
etc/NEWS
lisp/kmacro.el
lisp/macros.el
test/lisp/kmacro-tests.el