[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lisp error on function :documentation
From: |
Stefan Monnier |
Subject: |
Re: Lisp error on function :documentation |
Date: |
Sun, 16 Oct 2022 11:23:13 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
> Or maybe someone has added some nicer solution in the meantime? - I
> don't recall.
I don't know about nicer, but in Emacs-29, you can use `oclosure-lambda`
to build a function tagged with a certain type on which you can dispatch
via `cl-defmethod` and functions's docstrings are fetched via
`function-documentation` which is a generic function to which you can
add your own methods for your OClosure type, thus making it possible to
dynamically build your docstring.
We use it internally for the "accessor" functions that let you fetch the
value of an OClosure's slot:
(oclosure-define accessor
"OClosure function to access a specific slot of an object."
type slot)
(cl-defmethod function-documentation ((function accessor))
(oclosure--accessor-docstring function)) ;; FIXME: η-reduce!
(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)))
We could of course also prebuild those docstrings when we define each
accessor function, but with the above we avoid this cost upfront and
instead we compute those docstrings ondemand.
See also the `OClosures` section in the Texinfo docs.
Stefan
- Lisp error on function :documentation, Heime, 2022/10/15
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/15
- Re: Lisp error on function :documentation, Heime, 2022/10/15
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/15
- Re: Lisp error on function :documentation, Heime, 2022/10/15
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/16
- Re: Lisp error on function :documentation, Heime, 2022/10/16
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/16
- Re: Lisp error on function :documentation, Heime, 2022/10/16
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/16
- Re: Lisp error on function :documentation,
Stefan Monnier <=
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/16
- Re: Lisp error on function :documentation, Heime, 2022/10/16
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/16
- Re: Lisp error on function :documentation, Heime, 2022/10/16
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/16
- Re: Lisp error on function :documentation, Heime, 2022/10/16
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/16
- Re: Lisp error on function :documentation, Heime, 2022/10/16
- Re: Lisp error on function :documentation, Michael Heerdegen, 2022/10/16
- Re: Lisp error on function :documentation, Stefan Monnier, 2022/10/16