diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-04-07 15:59:09 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-04-07 15:59:09 -0400 |
commit | 39e8fd357dd0a1f3776c05eee2cc5be451686712 (patch) | |
tree | 7783c644dc02cef24ebb231d3aeb20292b0ec07d /lisp/emacs-lisp | |
parent | 3b411417086ceb2ce3838160d01c6f250e47bbf3 (diff) | |
download | emacs-39e8fd357dd0a1f3776c05eee2cc5be451686712.tar.gz emacs-39e8fd357dd0a1f3776c05eee2cc5be451686712.tar.bz2 emacs-39e8fd357dd0a1f3776c05eee2cc5be451686712.zip |
OClosure: New function `function-documentation`
As mentioned in the original OClosure commit, OClosures (ab)use the
bytecode's docstring slot to hold the OClosure's type. This currently
prevents OClosures from having their own docstring.
Introduce a new generic function `function-documentation` to fetch the
docstring of a function, which can then be implemented in various
different ways depending on the OClosure's type.
* lisp/simple.el (function-documentation): New generic function.
(bad-package-check): Strength-reduce `eval` to `symbol-value`.
* src/doc.c (Fdocumentation): Use it.
* lisp/emacs-lisp/oclosure.el (oclosure--accessor-docstring): New function.
* test/lisp/emacs-lisp/oclosure-tests.el (oclosure-test):
Add test for accessor's docstrings.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/oclosure.el | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/oclosure.el b/lisp/emacs-lisp/oclosure.el index 3df64ad2806..90811199f25 100644 --- a/lisp/emacs-lisp/oclosure.el +++ b/lisp/emacs-lisp/oclosure.el @@ -505,6 +505,12 @@ This has 2 uses: "OClosure function to access a specific slot of an object." type slot) +(defun oclosure--accessor-docstring (f) + ;; This would like to be a (cl-defmethod function-documentation ...) + ;; but for circularity reason the defmethod is in `simple.el'. + (format "Access slot \"%S\" of OBJ of type `%S'.\n\n(fn OBJ)" + (accessor--slot f) (accessor--type f))) + (oclosure-define (oclosure-accessor (:parent accessor) (:copier oclosure--accessor-copy (type slot index))) |