commit 584ecc887bb92133119f93a6716cdf7af0b51dca
parent dc40546747624ad86944177ebaa9fb30f9b70705
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Sun, 11 Oct 2020 23:14:42 -0700
Fix hang on autoload functions with advice
Fixes #179.
Fixes #191.
Diffstat:
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -1,6 +1,7 @@
# v0.19 (unreleased)
-No changes yet.
+Fixed a hang when looking at functions that had advice but hadn't yet
+been loaded by the autoloader (#179, #191).
# v0.18
diff --git a/helpful.el b/helpful.el
@@ -1610,7 +1610,7 @@ E.g. (x x y z y) -> ((x . 2) (y . 2) (z . 1))"
(defun helpful--without-advice (sym)
"Given advised function SYM, return the function object
-without the advice."
+without the advice. Assumes function has been loaded."
(advice--cd*r
(advice--symbol-function sym)))
@@ -2074,7 +2074,7 @@ may contain duplicates."
"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)))
+ (let ((fn-obj (symbol-function helpful--sym)))
(when (autoloadp fn-obj)
(autoload-do-load fn-obj)))))
diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el
@@ -1050,3 +1050,13 @@ find the source code."
(should (s-contains-p "Implementations" (buffer-string)))
(should (s-contains-p "((l xref-file-location))" (buffer-string)))
(should (s-contains-p "((l xref-buffer-location))" (buffer-string))))
+
+(defun helpful--boring-advice (orig-fn &rest args)
+ (apply orig-fn args))
+
+(advice-add 'ruby-mode :around #'helpful--boring-advice)
+
+(ert-deftest helpful--autoload-functions-with-advice ()
+ "Ensure that we can describe an autoloaded function
+that has advice attached before it is loadedl."
+ (helpful-function 'ruby-mode))