emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c53aff5: Add new help-enable-symbol-autoload user option


From: Lars Ingebrigtsen
Subject: master c53aff5: Add new help-enable-symbol-autoload user option
Date: Sat, 18 Sep 2021 13:53:20 -0400 (EDT)

branch: master
commit c53aff5de71d7c558c222c35fd1cda0298d834b1
Author: Arthur Miller <arthur.miller@live.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add new help-enable-symbol-autoload user option
    
    * 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 |  7 +++++++
 etc/NEWS            |  5 +++++
 lisp/help-fns.el    | 21 ++++++++++++++++++++-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi
index 0caab68..f7fcd20 100644
--- a/doc/emacs/help.texi
+++ b/doc/emacs/help.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index fd2408d..a0da78a 100644
--- 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.
 
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index ffbead3..63d3905 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]