1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Add functions to query Emacs Lisp examples registered in shortdoc

* lisp/emacs-lisp/shortdoc.el (shortdoc--display-function): Add
a new shortdoc-example text property so that ELisp examples can
be searched for later.
(shortdoc--insert-group-in-buffer): New function extracted from
the buffer insertion code in 'shortdoc-display-group'.
(shortdoc-display-group): Implement in terms of
'shortdoc--insert-group-in-buffer'.
(shortdoc-function-examples): New function that returns an alist
of Emacs Lisp examples from shortdoc.
(shortdoc-help-fns-examples-function): New function to insert
Emacs Lisp function examples in *Help* buffers, if added to
'help-fns-describe-function-functions'.
*
test/lisp/emacs-lisp/shortdoc-tests.el (shortdoc-function-examples-test):
Test it.
* doc/emacs/help.texi (Name Help): Document in the user manual.
* doc/lispref/help.texi (Documentation Groups): Document it.
* etc/NEWS: Advertise it. (Bug#61877)
This commit is contained in:
Daniel Martín 2023-02-28 23:15:40 +01:00 committed by Eli Zaretskii
parent 31f18480ca
commit 29227e7c19
5 changed files with 149 additions and 36 deletions

View file

@ -989,3 +989,29 @@ in the function group to insert the function into.
If @var{group} doesn't exist, it will be created. If @var{section}
doesn't exist, it will be added to the end of the function group.
@end defun
You can also query the examples of use of functions defined in
shortdoc groups.
@defun shortdoc-function-examples function
This function returns all shortdoc examples for @var{function}. The
result is an alist with items of the form
@example
(@var{group} . @var{examples})
@end example
@noindent
where @var{group} is a documentation group where @var{function}
appears in and @var{examples} is a string with the examples of use of
@var{function} defined in @var{group}.
@code{shortdoc-function-examples} returns @code{nil} if @var{function}
is not a function or if it doesnt contain shortdoc information.
@end defun
@defun shortdoc-help-fns-examples-function function
This function queries the registered documentation groups and inserts
examples of use of a given Emacs Lisp function into the current
buffer.
@end defun