Heime <[email protected]> writes:
> ------------------------------------------------------------------------
> I want to add text to the `help-fns-describe-function-functions` hook
> using a generic property.
>
> The problem is that `help-fns-describe-function-functions` only accepts
> the function symbol as argument.
>
> How Can I make the function specify the property without breaking the
> requirement of the `help-fns-describe-function-functions` hook?
>
> (defun ripo-insert-property (fn property)
> "Add property text into the `*Help*' buffer during `describe-function'
> for functions where PROPERTY is set to their symbol.
>
> (add-hook 'help-fns-describe-function-functions #'ripo-insert-property)
>
> Enhance the `*Help*' buffer by adding the property value to the
> `help-fns-describe-function-functions' hook."
>
> ;; Retrieve and insert the property value if present
> ;; Conditional let construct binds variable VALR and runs body when
> ;; binding is non‑nil.
> (when-let* ((valr (get fn property)))
> (insert (format "%s\n\n" valr))))
>
Because the functions listed in
‘help-fns-describe-function-functions’ will be called with
only one argument (the function’s symbol), it is not
possible to pass the ‘property’ argument to your function
as you have specified in your function definition.
That variable, ‘property’, will need to be supplied its
value before the function ‘ripo-insert-property’ is called.
To do this, you will need to define a global variable AND
guarantee that its value has been set BEFORE your function
is called.
See (info "(elisp) Defining Variables"), which documents
‘defvar’ and ‘defconst’.
You could, for example, define an association list (alist)
where the keys in the list were symbols for functions and
the values were the names of properties. Your function
could then use that alist to retrieve a property for a given
function name.
See also:
(shortdoc-display-group 'alist)
--
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.