This is done simply so as to avoid scattering nadvice's code into
`simple.el` and `cl-print.el`.
* lisp/loadup.el ("emacs-lisp/nadvice"): Move down after "simple".
* lisp/help.el (help-command-error-confusable-suggestions): Make it
call `command-error-default`.
(command-error-function): Replace the top-level call to `add-function`
with a simple `setq` since `add-function` is not available at this
stage any more.
* lisp/emacs-lisp/nadvice.el (interactive-form) <advice>:
(cl-print-object) <advice>: Rename from `advice--get-interactive-form`
and `advice--cl-print-object`.
* lisp/emacs-lisp/cl-print.el (cl-print-object) <advice>:
* lisp/simple.el (interactive-form) <advice>: Move to `nadvice.el`.
(pre-redisplay-function): Replace the top-level call to `add-function`
with a simple `setq` since `add-function` is not available at this
stage any more.
* lisp/emacs-lisp/cl-generic.el: Use `oclosure-object` instead of `advice`
as representative of the OClosure specializers to prefill the dispatcher table.
This is done simply so as to avoid scattering nadvice's code into
`simple.el` and `cl-print.el`.
* lisp/loadup.el ("emacs-lisp/nadvice"): Move down after "simple".
* lisp/help.el (help-command-error-confusable-suggestions): Make it
call `command-error-default`.
(command-error-function): Replace the top-level call to `add-function`
with a simple `setq` since `add-function` is not available at this
stage any more.
* lisp/emacs-lisp/nadvice.el (interactive-form) <advice>:
(cl-print-object) <advice>: Rename from `advice--get-interactive-form`
and `advice--cl-print-object`.
* lisp/emacs-lisp/cl-print.el (cl-print-object) <advice>:
* lisp/simple.el (interactive-form) <advice>: Move to `nadvice.el`.
(pre-redisplay-function): Replace the top-level call to `add-function`
with a simple `setq` since `add-function` is not available at this
stage any more.
* lisp/emacs-lisp/cl-generic.el: Use `fcr-object` instead of `advice`
as representative of the FCR specializers to prefill the dispatcher table.
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 OClosure so it's directly executable.
Take advantage of the change to promote the key-description
format where applicable.
* lisp/kmacro.el (kmacro): New OClosure 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 OClosure 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.
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.
* src/buffer.c (Frename_buffer): Call `uniquify--rename-buffer-advice`.
* lisp/files.el (create-file-buffer):
Call`uniquify--create-file-buffer-advice`.
* lisp/uniquify.el (uniquify--rename-buffer-advice)
(uniquify--create-file-buffer-advice): Don't add them as advice any more.
Adjust their calling convention accordingly.
* src/buffer.c (Frename_buffer): Call `uniquify--rename-buffer-advice`.
* lisp/files.el (create-file-buffer):
Call`uniquify--create-file-buffer-advice`.
* lisp/uniquify.el (uniquify--rename-buffer-advice)
(uniquify--create-file-buffer-advice): Don't add them as advice any more.
Adjust their calling convention accordingly.
* lisp/emacs-lisp/oclosure.el (oclosure--defstruct-make-copiers): Adjust for the
case of mutable slots. Optimize the mandatory arg case.
Don't mark the copiers as inlinable.
(oclosure-define): Allow `:type` and `:mutable` properties on slots.
(oclosure--lambda): Add `mutables` arg.
(oclosure-lambda): Pass it.
(oclosure--copy): Add `mutlist` arg.
(oclosure--get): Add `mutable` arg.
(oclosure--set): New function.
(oclosure--mut-getter-prototype, oclosure--mut-setter-prototype):
New prototype functions.
* test/lisp/emacs-lisp/oclosure-tests.el (oclosure-test, oclosure-tests):
Add test for copier with mandatory arg.
(oclosure-test-mut, oclosure-test--mutate): New test.
* lisp/emacs-lisp/nadvice.el (advice): Use separate copiers
for the two use-cases, to avoid relying on CL keywords, since they're
not optimized away via inlining any more.
(advice--make, advice--tweak): Adjust accordingly.
* lisp/emacs-lisp/fcr.el (fcr--defstruct-make-copiers): Adjust for the
case of mutable slots. Optimize the mandatory arg case.
Don't mark the copiers as inlinable.
(fcr-defstruct): Allow `:type` and `:mutable` properties on slots.
(fcr--lambda): Add `mutables` arg.
(fcr-lambda): Pass it.
(fcr--copy): Add `mutlist` arg.
(fcr--get): Add `mutable` arg.
(fcr--set): New function.
(fcr--mut-getter-prototype, fcr--mut-setter-prototype):
New prototype functions.
* test/lisp/emacs-lisp/fcr-tests.el (fcr-test, fcr-tests):
Add test for copier with mandatory arg.
(fcr-test-mut, fcr-test--mutate): New test.
* lisp/emacs-lisp/nadvice.el (advice): Use separate copiers
for the two use-cases, to avoid relying on CL keywords, since they're
not optimized away via inlining any more.
(advice--make, advice--tweak): Adjust accordingly.
* lisp/emacs-lisp/oclosure.el (oclosure-define): Use `oclosure--copy` to
define accessors. Fix call to `oclosure--defstruct-make-copiers`.
(oclosure--lambda): New macro extracted from `oclosure-lambda`.
(oclosure-lambda): Use it.
(oclosure--accessor-prototype): New constant.
(oclosure-accessor): New type.
* lisp/emacs-lisp/fcr.el (fcr-defstruct): Use `fcr--copy` to
define accessors. Fix call to `fcr--defstruct-make-copiers`.
(fcr--lambda): New macro extracted from `fcr-lambda`.
(fcr-lambda): Use it.
(fcr--accessor-prototype): New constant.
(fcr-accessor): New type.
* lisp/emacs-lisp/oclosure.el (accessor): New (OClosure) type.
(oclosure-define): Mark the accessor functions
as being of type `accessor`.
(oclosure--accessor-cl-print, oclosure--accessor-docstring): New functions.
* src/doc.c (store_function_docstring): Improve message and fix check.
* lisp/simple.el (function-docstring) <accessor>: New method.
* lisp/emacs-lisp/cl-print.el (cl-print-object) <accessor>: New method.
* lisp/emacs-lisp/fcr.el (accessor): New (FCR) type.
(fcr-defstruct): Mark the accessor functions
as being of type `accessor`.
(fcr--accessor-cl-print, fcr--accessor-docstring): New functions.
* src/doc.c (store_function_docstring): Improve message and fix check.
* lisp/simple.el (function-docstring) <accessor>: New method.
* lisp/emacs-lisp/cl-print.el (cl-print-object) <accessor>: New method.
* test/lisp/emacs-lisp/oclosure-tests.el (oclosure-tests): Remove left-over
debugging messages.
(oclosure-tests--limits): New test.
* lisp/emacs-lisp/oclosure.el (oclosure-define): Fill the `index-table` and
signal an error in case of duplicate slot names.
(oclosure-lambda): Change use of `oclosure--fix-type` so `cconv-convert` can use
it to detect store-converted slots. Tweak generated code to avoid
a warning.
(oclosure--fix-type): Adjust accordingly.
* lisp/emacs-lisp/cconv.el (cconv-convert): Signal an error if we
store-convert a OClosure slot.
* test/lisp/emacs-lisp/fcr-tests.el (fcr-tests): Remove left-over
debugging messages.
(fcr-tests--limits): New test.
* lisp/emacs-lisp/fcr.el (fcr-defstruct): Fill the `index-table` and
signal an error in case of duplicate slot names.
(fcr-lambda): Change use of `fcr--fix-type` so `cconv-convert` can use
it to detect store-converted slots. Tweak generated code to avoid
a warning.
(fcr--fix-type): Adjust accordingly.
* lisp/emacs-lisp/cconv.el (cconv-convert): Signal an error if we
store-convert a FCR slot.
* test/lisp/emacs-lisp/cconv-tests.el: Remove `:expected-result :failed`
from the bug#28557 tests.
(cconv-tests-cl-function-:documentation): Account for the presence of
the arglist (aka "usage") in the docstring.
* lisp/emacs-lisp/cl-macs.el (cl--transform-lambda):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric):
Handle non-constant `:documentation`.
* lisp/emacs-lisp/generator.el (iter-lambda):
* lisp/emacs-lisp/oclosure.el (oclosure-lambda):
* lisp/emacs-lisp/cconv.el (cconv--convert-funcbody):
Use `macroexp-parse-body`.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
Fix misuse of `cl-lib` without requiring it.
* test/lisp/emacs-lisp/cconv-tests.el: Remove `:expected-result :failed`
from the bug#28557 tests.
(cconv-tests-cl-function-:documentation): Account for the presence of
the arglist (aka "usage") in the docstring.
* lisp/emacs-lisp/cl-macs.el (cl--transform-lambda):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric):
Handle non-constant `:documentation`.
* lisp/emacs-lisp/generator.el (iter-lambda):
* lisp/emacs-lisp/fcr.el (fcr-lambda):
* lisp/emacs-lisp/cconv.el (cconv--convert-funcbody):
Use `macroexp-parse-body`.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
Fix misuse of `cl-lib` without requiring it.
* test/lisp/emacs-lisp/nadvice-tests.el (advice-test-print): New test.
* src/doc.c (store_function_docstring): Don't overwrite an OClosure type.
* lisp/simple.el (function-docstring): Don't return OClosures's type.
* lisp/emacs-lisp/nadvice.el (advice--cl-print-object): New function,
extracted from `cl-print-object`.
* lisp/emacs-lisp/cl-print.el (cl-print-object) <advice>: Use the
`advice` type for the dispatch. Use `advice--cl-print-object`.
* test/lisp/emacs-lisp/nadvice-tests.el (advice-test-print): New test.
* src/doc.c (store_function_docstring): Don't overwrite an FCR type.
* lisp/simple.el (function-docstring): Don't return FCRs's type.
* lisp/emacs-lisp/nadvice.el (advice--cl-print-object): New function,
extracted from `cl-print-object`.
* lisp/emacs-lisp/cl-print.el (cl-print-object) <advice>: Use the
`advice` type for the dispatch. Use `advice--cl-print-object`.
* lisp/emacs-lisp/nadvice.el (advice): New OClosure type.
(advice--where-alist): Use OClosures.
(advice--car, advice--cdr, advice--props, advice--where):
Delete functions, now defined for us by `oclosure-define`.
(advice--p): Rewrite.
(advice--make-1): Delete function.
(advice--make, advice--tweak): Use `advice--copy` instead.
* lisp/emacs-lisp/oclosure.el (oclosure--fix-type): Don't use `documentation` to
avoid bootstrap problems.
(oclosure-type): Return nil on non-function objects.
* lisp/help.el (help--docstring-quote, help-add-fundoc-usage)
(help--make-usage, help--make-usage-docstring): Move to `subr.el`.
* lisp/subr.el (docstring--quote, docstring-add-fundoc-usage)
(docstring--make-usage, docstring--make-usage-docstring): New names for
functions moved from `help.el` for bootstrap reasons.
* lisp/emacs-lisp/cl-macs.el (cl--transform-lambda): Use the new names.
* lisp/emacs-lisp/nadvice.el (advice): New FCR type.
(advice--where-alist): Use FCRs.
(advice--car, advice--cdr, advice--props, advice--where):
Delete functions, now defined for us by `fcr-defstruct`.
(advice--p): Rewrite.
(advice--make-1): Delete function.
(advice--make, advice--tweak): Use `advice--copy` instead.
* lisp/emacs-lisp/fcr.el (fcr--fix-type): Don't use `documentation` to
avoid bootstrap problems.
(fcr-type): Return nil on non-function objects.
* lisp/help.el (help--docstring-quote, help-add-fundoc-usage)
(help--make-usage, help--make-usage-docstring): Move to `subr.el`.
* lisp/subr.el (docstring--quote, docstring-add-fundoc-usage)
(docstring--make-usage, docstring--make-usage-docstring): New names for
functions moved from `help.el` for bootstrap reasons.
* lisp/emacs-lisp/cl-macs.el (cl--transform-lambda): Use the new names.
* lisp/simple.el (function-docstring): Fix call to `signal`.
* lisp/emacs-lisp/oclosure.el (oclosure--define): Use `cl-deftype-satisfies`.
* lisp/emacs-lisp/cl-generic.el (cl--generic-prefill-dispatchers):
Bind `cl--generic-compiler` around the right part of the function (duh!).
* lisp/simple.el (function-docstring): Fix call to `signal`.
* lisp/emacs-lisp/fcr.el (fcr--define): Use `cl-deftype-satisfies`.
* lisp/emacs-lisp/cl-generic.el (cl--generic-prefill-dispatchers):
Bind `cl--generic-compiler` around the right part of the function (duh!).
Change `interactive-form` to be a generic function, and
change `documentation` to delegate to a new `function-docstring`
generic function so that we can use `cl-defmethod` to construct
the docstrings and interactive forms of OClosures.
* src/eval.c (Fcommandp): Rewrite to delegate to `interactive-form`
when potentially necessary.
* src/doc.c (Fdocumentation): Delegate to `function-docstring` in
most cases.
* src/data.c (Finternal__interactive_form): Rename from
`Finteractive_form` and simplify to only handle the cases we can't (yet)
handle from Lisp.
(syms_of_data): Adjust accordingly.
* src/callint.c (Fcall_interactively): `interactive-form` is now
defined in Lisp.
* lisp/simple.el: Require `subr-x`.
(function-docstring, interactive-form): New generic functions.
* lisp/loadup.el ("simple"): Postpone loading it after `cl-generic`.
* lisp/emacs-lisp/macroexp.el (internal-macroexpand-for-load):
Don't neuter eager macroexpansion errors.
* lisp/emacs-lisp/cl-generic.el (cl--generic-lambda):
Avoid `interactive-form` to avoid breaking bootstrap since it's now
defined as a generic function.
(cl-defmethod): Simplify.
(cl--generic-compiler): New var.
(cl--generic-get-dispatcher): Use it.
(cl--generic-prefill-dispatchers): Rebind it.
Change `interactive-form` to be a generic function, and
change `documentation` to delegate to a new `function-docstring`
generic function so that we can use `cl-defmethod` to construct
the docstrings and interactive forms of FCRs.
* src/eval.c (Fcommandp): Rewrite to delegate to `interactive-form`
when potentially necessary.
* src/doc.c (Fdocumentation): Delegate to `function-docstring` in
most cases.
* src/data.c (Finternal__interactive_form): Rename from
`Finteractive_form` and simplify to only handle the cases we can't (yet)
handle from Lisp.
(syms_of_data): Adjust accordingly.
* src/callint.c (Fcall_interactively): `interactive-form` is now
defined in Lisp.
* lisp/simple.el: Require `subr-x`.
(function-docstring, interactive-form): New generic functions.
* lisp/loadup.el ("simple"): Postpone loading it after `cl-generic`.
* lisp/emacs-lisp/macroexp.el (internal-macroexpand-for-load):
Don't neuter eager macroexpansion errors.
* lisp/emacs-lisp/cl-generic.el (cl--generic-lambda):
Avoid `interactive-form` to avoid breaking bootstrap since it's now
defined as a generic function.
(cl-defmethod): Simplify.
(cl--generic-compiler): New var.
(cl--generic-get-dispatcher): Use it.
(cl--generic-prefill-dispatchers): Rebind it.
* lisp/loadup.el (oclosure): Load before `nadvice`.
* lisp/emacs-lisp/cl-generic.el (cl--generic-class-parents): Move to
`cl-preloaded.el`.
(cl--generic-struct-specializers, cl-generic--oclosure-specializers)
(cl--generic-specializers-apply-to-type-p): Use its new name.
* lisp/emacs-lisp/cl-preloaded.el (cl--class-allparents): New function
moved from `cl-generic.el`.
* lisp/emacs-lisp/oclosure.el (oclosure-define): Use it.
* lisp/emacs-lisp/cl-macs.el (pcase--mutually-exclusive-p):
Don't advise if `nadvice` has not yet been loaded.
* lisp/loadup.el (fcr): Load before `nadvice`.
* lisp/emacs-lisp/cl-generic.el (cl--generic-class-parents): Move to
`cl-preloaded.el`.
(cl--generic-struct-specializers, cl-generic--fcr-specializers)
(cl--generic-specializers-apply-to-type-p): Use its new name.
* lisp/emacs-lisp/cl-preloaded.el (cl--class-allparents): New function
moved from `cl-generic.el`.
* lisp/emacs-lisp/fcr.el (fcr-defstruct): Use it.
* lisp/emacs-lisp/cl-macs.el (pcase--mutually-exclusive-p):
Don't advise if `nadvice` has not yet been loaded.
* lisp/emacs-lisp/oclosure.el (oclosure--define): Avoid `cl-lib` at run-time.
(oclosure--type-sym): Delete variable. Use an interned symbol instead,
so the closures stand a chance of being printable readably.
(oclosure--fix-type, oclosure--copy, oclosure-get, oclosure-type): Adjust accordingly.
* lisp/emacs-lisp/cl-generic.el (cl--generic-nnm): New OClosure type.
(cl--generic-no-next-method-function): Delete function.
(cl-generic-call-method): Use it for the default no-next-method case.
(cl--generic-nnm-sample, cl--generic-cnm-sample): Delete vars.
(cl--generic-isnot-nnm-p): Use `oclosure-type`.
* lisp/emacs-lisp/fcr.el (fcr--define): Avoid `cl-lib` at run-time.
(fcr--type-sym): Delete variable. Use an interned symbol instead,
so the closures stand a chance of being printable readably.
(fcr--fix-type, fcr--copy, fcr-get, fcr-type): Adjust accordingly.
* lisp/emacs-lisp/cl-generic.el (cl--generic-nnm): New FCR type.
(cl--generic-no-next-method-function): Delete function.
(cl-generic-call-method): Use it for the default no-next-method case.
(cl--generic-nnm-sample, cl--generic-cnm-sample): Delete vars.
(cl--generic-isnot-nnm-p): Use `fcr-type`.
* lisp/loadup.el: Load `oclosure`.
* lisp/emacs-lisp/oclosure.el: Don't use `cl-lib` at runtime.
(oclosure--copy): Use `named-let` instead of `cl-mapcar`.
(oclosure--struct-tag, oclosure--struct-specializers, oclosure--struct-generalizer)
(cl-generic-generalizers): Move cl-generic support to cl-generic.
* lisp/emacs-lisp/cl-generic.el (cl--generic-oclosure-tag)
(cl-generic--oclosure-specializers, cl-generic--oclosure-generalizer)
(cl-generic-generalizers): Move OClosure support from `oclosure.el`.
* lisp/loadup.el: Load `fcr`.
* lisp/emacs-lisp/fcr.el: Don't use `cl-lib` at runtime.
(fcr--copy): Use `named-let` instead of `cl-mapcar`.
(fcr--struct-tag, fcr--struct-specializers, fcr--struct-generalizer)
(cl-generic-generalizers): Move cl-generic support to cl-generic.
* lisp/emacs-lisp/cl-generic.el (cl--generic-fcr-tag)
(cl-generic--fcr-specializers, cl-generic--fcr-generalizer)
(cl-generic-generalizers): Move FCR support from `fcr.el`.