]> git.eshelyaron.com Git - emacs.git/commitdiff
Add new help-enable-symbol-autoload user option
authorArthur Miller <arthur.miller@live.com>
Sat, 18 Sep 2021 17:51:47 +0000 (19:51 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 18 Sep 2021 17:51:47 +0000 (19:51 +0200)
* lisp/help-fns.el (help-fns--analyze-function): Use it.
* lisp/help-fns.el (help-enable-symbol-autoload): New user option.
* doc/emacs/help.texi (Name Help): Document it.

doc/emacs/help.texi
etc/NEWS
lisp/help-fns.el

index 0caab681d347b55aeda389fe805b191c5645ed30..f7fcd207ee15bc7657ac022d8fb3f894155a4759 100644 (file)
@@ -278,6 +278,13 @@ name is defined as a Lisp function.  Type @kbd{C-g} to cancel the
 @kbd{C-h f} command if you don't really want to view the
 documentation.
 
+@vindex help-enable-symbol-autoload
+  If you request help for an autoloaded function that doesn't have a
+doc string, the @file{*Help*} buffer won't have any doc string to
+display.  If @code{help-enable-symbol-autoload} is non-@code{nil},
+Emacs will try to load the file the function is defined in to see
+whether there's a doc string there.
+
 @findex shortdoc-display-group
   You can get an overview of functions relevant for a particular topic
 by using the @kbd{M-x shortdoc-display-group} command.  This will
index fd2408d7933284db0038d8fd94eff6ab60bd47ae..a0da78a1f613fc373b38bf9aadcc44cccf657f10 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -586,6 +586,11 @@ be assumed to be a propertized string.
 Note that the new face will also be used in tooltips.  When using the
 GTK toolkit, this is only true if 'x-gtk-use-system-tooltips' is t.
 
+*** New user option 'help-enable-symbol-autoload'.
+If non-nil, displaying help for an autoloaded function that has no
+documentation string will try to load the file it's from.  This will
+give more extensive help for these functions.
+
 ---
 *** The 'help-for-help' ('C-h C-h') screen has been redesigned.
 
index ffbead33982617e5ea30923cf76588a18954bb82..63d3905a94a8447720bb8951ff3e57b88bc3b496 100644 (file)
@@ -132,6 +132,12 @@ with the current prefix.  The files are chosen according to
   :group 'help
   :version "26.3")
 
+(defcustom help-enable-symbol-autoload nil
+  "Perform autoload if docs are missing from autoload objects."
+  :type 'boolean
+  :group 'help
+  :version "28.1")
+
 (defun help--symbol-class (s)
   "Return symbol class characters for symbol S."
   (when (stringp s)
@@ -227,7 +233,10 @@ interactive command."
 ;;;###autoload
 (defun describe-function (function)
   "Display the full documentation of FUNCTION (a symbol).
-When called from Lisp, FUNCTION may also be a function object."
+When called from Lisp, FUNCTION may also be a function object.
+
+See the `help-enable-symbol-autoload' variable for special
+handling of autoloaded functions."
   (interactive (help-fns--describe-function-or-command-prompt))
 
   ;; We save describe-function-orig-buffer on the help xref stack, so
@@ -823,6 +832,16 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)."
                        f))
                    ((subrp def) (intern (subr-name def)))
                     (t def))))
+
+    ;; If we don't have a doc string, then try to load the file.
+    (when (and help-enable-symbol-autoload
+               (autoloadp real-def)
+               ;; Empty documentation slot.
+               (not (nth 2 real-def)))
+      (condition-case err
+          (autoload-do-load real-def)
+        (error (message "Error while autoloading: %S" err))))
+
     (list real-function def aliased real-def)))
 
 (defun help-fns-function-description-header (function)