commit 7319a7a638fc2f8bcea5d1ffecab13a4c18818cf
parent d0ca3cf6ff3f5921e62bdc46f2827353532963f8
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Fri, 29 Sep 2017 05:01:14 +0100
Merge pull request #42 from narendraj9/master
Handle functions not yet loaded, gracefully
Diffstat:
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/helpful.el b/helpful.el
@@ -675,9 +675,12 @@ For example, \"(some-func FOO &optional BAR)\"."
(let (docstring-sig
source-sig)
;; Get the usage from the function definition.
- (let ((formatted-args
- (-map #'helpful--format-argument
- (help-function-arglist sym))))
+ (let* ((function-args (help-function-arglist sym))
+ (formatted-args
+ (if (listp function-args)
+ (-map #'helpful--format-argument
+ function-args)
+ (list function-args))))
(setq source-sig
(if formatted-args
(format "(%s %s)" sym
diff --git a/test/unit-test.el b/test/unit-test.el
@@ -9,6 +9,8 @@
"Docstring here too."
nil)
+(autoload 'some-unused-function "somelib.el")
+
(defadvice test-foo-advised (before test-advice1 activate)
"Placeholder advice 1."
nil)
@@ -112,3 +114,9 @@ variables defined without `defvar'."
(ert-deftest helpful-variable ()
"Smoke test for `helpful-variable'."
(helpful-variable 'tab-width))
+
+(ert-deftest helpfpul--signature ()
+ "Ensure that autoloaded functions are handled gracefully"
+ (should
+ (equal (helpful--signature 'some-unused-function)
+ "(some-unused-function [Arg list not available until function definition is loaded.])")))