diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2018-02-20 19:57:38 +0000 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2018-02-20 19:57:38 +0000 |
| commit | 954d4e8eaa61ab7573c591acb90f8f04797ead16 (patch) | |
| tree | 703c06b79bfeaa92bb3802186602db38310c18b1 | |
| parent | c5a5965017606fa703cdfabdac1441483ad72e9c (diff) | |
Support functions defined in non-file buffers
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | helpful.el | 28 |
2 files changed, 27 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f0fd209..57af2af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ a plain symbol. Fixed an issue where we would show function source code for variables where we can't find the variable definition. +Fixed a crash on functions defined in a buffer that isn't backed by a +file. We now provide a button to navigate to that buffer. + # v0.7 Helpful buffers now start with a summary of what you're looking at, @@ -411,6 +411,23 @@ or disable if already enabled." 'path path 'position pos)) +(define-button-type 'helpful-buffer-button + 'action #'helpful--switch-to-buffer + 'buffer nil + 'follow-link t + 'help-echo "Switch to this buffer") + +(defun helpful--switch-to-buffer (button) + "Navigate to the buffer this BUTTON represents." + (switch-to-buffer (button-get button 'buffer))) + +(defun helpful--buffer-button (buffer) + "Return a button that opens PATH and puts point at POS." + (helpful--button + (buffer-name buffer) + 'helpful-buffer-button + 'buffer buffer)) + (define-button-type 'helpful-customize-button 'action #'helpful--customize 'symbol nil @@ -1289,10 +1306,13 @@ OBJ may be a symbol or a compiled function object." (cond (buf (let ((path (buffer-file-name buf))) - (format - "defined in %s" - (helpful--navigate-button - (file-name-nondirectory path) path pos)))) + (if path + (format + "defined in %s" + (helpful--navigate-button + (file-name-nondirectory path) path pos)) + (format "defined in buffer %s" + (helpful--buffer-button buf))))) (primitive-p "defined in C source code") (t |
