diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2019-10-01 01:09:06 +0100 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2019-10-01 01:09:06 +0100 |
| commit | e2609e4ae9e058bd8be6239681b2f22195628f28 (patch) | |
| tree | 7db6f677da60e13b9ca8577787d79da088e8b0d9 | |
| parent | 3b0f42e77d05cf38a90a34dca76600df800d02b7 (diff) | |
Handle byte-compiled functions bound to keys
Fixes #212
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | helpful.el | 11 | ||||
| -rw-r--r-- | test/helpful-unit-test.el | 14 |
3 files changed, 24 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 5432d85..fef5657 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Show the original value for custom variables whose value has changed. Report the package version when custom variables were added. +Fixed a crash on assigning byte-compiled objects to keybindings. + # v0.17 Fixed a minor docstring formatting issue when keymap references were @@ -2373,9 +2373,14 @@ For example, \"(some-func FOO &optional BAR)\"." (gethash (symbol-function sym) advertised-signature-table)))) ;; Get the usage from the function definition. (let* ((function-args - (if (symbolp sym) - (help-function-arglist sym) - (cadr sym))) + (cond + ((symbolp sym) + (help-function-arglist sym)) + ((byte-code-function-p sym) + (aref sym 0)) + (t + ;; Interpreted function (lambda ...) + (cadr sym)))) (formatted-args (cond (advertised-args diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el index 14d44dc..596bd8c 100644 --- a/test/helpful-unit-test.el +++ b/test/helpful-unit-test.el @@ -533,6 +533,20 @@ associated a lambda with a keybinding." (with-current-buffer buf (helpful-update)))) +(ert-deftest helpful--unnamed-compiled-func () + "Ensure we handle unnamed byte-compiled functions. + +This is important for `helpful-key', where a user may have +associated a lambda with a keybinding." + (let* ((fun (byte-compile (lambda (x) x))) + (buf (helpful--buffer fun t))) + ;; There's no name, so just show lambda in the buffer name. + (should + (equal (buffer-name buf) "*helpful lambda*")) + ;; Don't crash when we show the buffer. + (with-current-buffer buf + (helpful-update)))) + (ert-deftest helpful--obsolete-variable () "Test display of obsolete variable." (let* ((var 'helpful-test-var-obsolete) |
