helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit f0bb06dea83c2c9490f2f962d4032f23d15e6b76
parent bf1d05334352d2546effc93de301bda31fec83d3
Author: Narendra Joshi <narendraj9@gmail.com>
Date:   Wed, 27 Sep 2017 19:27:24 +0530

Handle not yet loaded functions gracefully

Diffstat:
Mhelpful.el | 9++++++---
Mtest/unit-test.el | 8++++++++
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/helpful.el b/helpful.el @@ -681,9 +681,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.])")))