aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md5
-rw-r--r--helpful.el9
-rw-r--r--test/helpful-unit-test.el11
3 files changed, 25 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ecacc4a..bab2fa5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,11 @@ Added looking up C-style Lisp names.
Set `comment-start` inside helpful buffers, to fix external packages
relying on that variable.
+Helpful now always autoloads callables if they aren't already
+loaded. This is consistent with help.el (unless you've overriden
+`help-enable-auto-load`), produces more useful results, and fixes
+crashes rendering some docstrings.
+
# v0.15
Fixed a crash on formatting values.
diff --git a/helpful.el b/helpful.el
index efbe1d3..828be1b 100644
--- a/helpful.el
+++ b/helpful.el
@@ -1926,6 +1926,14 @@ may contain duplicates."
(-flatten
(-map #'helpful--callees-1 (cdr form)))))))
+(defun helpful--ensure-loaded ()
+ "Ensure the symbol associated with the current buffer has been loaded."
+ (when (and helpful--callable-p
+ (symbolp helpful--sym))
+ (let ((fn-obj (helpful--without-advice helpful--sym)))
+ (when (autoloadp fn-obj)
+ (autoload-do-load fn-obj)))))
+
(defun helpful-update ()
"Update the current *Helpful* buffer to the latest
state of the current symbol."
@@ -1933,6 +1941,7 @@ state of the current symbol."
(cl-assert (not (null helpful--sym)))
(unless (buffer-live-p helpful--associated-buffer)
(setq helpful--associated-buffer nil))
+ (helpful--ensure-loaded)
(-let* ((val
;; Look at the value before setting `inhibit-read-only', so
;; users can see the correct value of that variable.
diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el
index bfe887c..0e660bb 100644
--- a/test/helpful-unit-test.el
+++ b/test/helpful-unit-test.el
@@ -880,3 +880,14 @@ find the source code."
(helpful--convert-c-name 'Fmake_string t))
(should-not
(helpful--convert-c-name 'Vgc_cons_percentage nil)))
+
+(ert-deftest helpful--loads-autoload-symbol ()
+ "When asked to describe an autoloaded symbol, just load it."
+ ;; This test assumes that you haven't loaded tetris.el.gz in your
+ ;; current instance.
+ (skip-unless (autoloadp (symbol-function 'tetris)))
+ ;; This is a regression test: `tetris' has `tetris-mode-map' in its
+ ;; docstring, so we can't display the mode map unless tetris.el.gz is
+ ;; loaded.
+ ;;
+ (helpful-function #'tetris))