diff options
Diffstat (limited to 'helpful.el')
| -rw-r--r-- | helpful.el | 135 |
1 files changed, 82 insertions, 53 deletions
@@ -1006,6 +1006,77 @@ POSITION-HEADS takes the form ((123 (defun foo)) (456 (defun bar)))." (kill-buffer buf) return-value))) +(defun helpful--make-manual-button (sym) + "Make manual button for SYM." + (helpful--button + "View in manual" + 'helpful-manual-button + 'symbol sym)) + +(defun helpful--make-toggle-button (sym buffer) + "Make toggle button for SYM in BUFFER." + (helpful--button + "Toggle" + 'helpful-toggle-button + 'symbol sym + 'buffer buffer)) + +(defun helpful--make-set-button (sym buffer) + "Make set button for SYM in BUFFER." + (helpful--button + "Set" + 'helpful-set-button + 'symbol sym + 'buffer buffer)) + +(defun helpful--make-customize-button (sym) + "Make customize button for SYM." + (helpful--button + "Customize" + 'helpful-customize-button + 'symbol sym)) + +(defun helpful--make-references-button (sym callable-p) + "Make references button for SYM." + (helpful--button + "Find all references" + 'helpful-all-references-button + 'symbol sym + 'callable-p callable-p)) + +(defun helpful--make-edebug-button (sym) + "Make edebug button for SYM." + (helpful--button + (format "%s edebug" + (if (helpful--edebug-p sym) + "Disable" "Enable")) + 'helpful-edebug-button + 'symbol sym)) + +(defun helpful--make-tracing-button (sym) + "Make tracing button for SYM." + (helpful--button + (format "%s tracing" + (if (trace-is-traced sym) + "Disable" "Enable")) + 'helpful-trace-button + 'symbol sym)) + +(defun helpful--make-disassemble-button (sym) + "Make disassemble button for SYM." + (helpful--button + "Disassemble" + 'helpful-disassemble-button + 'symbol sym)) + +(defun helpful--make-forget-button (sym callable-p) + "Make forget button for SYM." + (helpful--button + "Forget" + 'helpful-forget-button + 'symbol sym + 'callable-p callable-p)) + (defun helpful-update () "Update the current *Helpful* buffer to the latest state of the current symbol." @@ -1047,12 +1118,8 @@ state of the current symbol." (helpful--heading (format "%s Documentation" sym-type)) (helpful--format-docstring docstring)) (when (helpful--in-manual-p helpful--sym) - (insert - "\n\n" - (helpful--button - "View in manual" - 'helpful-manual-button - 'symbol helpful--sym)))) + (insert "\n\n") + (insert (helpful--make-manual-button helpful--sym)))) (when (not helpful--callable-p) (helpful--insert-section-break) @@ -1064,26 +1131,10 @@ state of the current symbol." (helpful--sym-value sym buf)) "\n\n") (when (memq (helpful--sym-value helpful--sym buf) '(nil t)) - (insert - (helpful--button - "Toggle" - 'helpful-toggle-button - 'symbol helpful--sym - 'buffer buf) - " ")) - (insert - (helpful--button - "Set" - 'helpful-set-button - 'symbol helpful--sym - 'buffer buf)) + (insert (helpful--make-toggle-button helpful--sym buf) " ")) + (insert (helpful--make-set-button helpful--sym buf)) (when (custom-variable-p helpful--sym) - (insert - " " - (helpful--button - "Customize" - 'helpful-customize-button - 'symbol helpful--sym))))) + (insert " " (helpful--make-customize-button helpful--sym))))) ;; Show keybindings. ;; TODO: allow users to conveniently add and remove keybindings. @@ -1094,6 +1145,7 @@ state of the current symbol." (helpful--format-keys helpful--sym))) (helpful--insert-section-break) + (insert (helpful--heading "References") (cond @@ -1110,11 +1162,7 @@ state of the current symbol." (t "Could not find source file.")) "\n\n" - (helpful--button - "Find all references" - 'helpful-all-references-button - 'symbol helpful--sym - 'callable-p helpful--callable-p)) + (helpful--make-references-button helpful--sym helpful--callable-p)) (when (helpful--advised-p helpful--sym) (helpful--insert-section-break) @@ -1140,22 +1188,12 @@ state of the current symbol." (insert (helpful--heading "Debugging"))) (when can-edebug (insert - (helpful--button - (if (helpful--edebug-p helpful--sym) - "Disable edebug" - "Enable edebug") - 'helpful-edebug-button - 'symbol helpful--sym))) + (helpful--make-edebug-button helpful--sym))) (when can-trace (when can-edebug (insert " ")) (insert - (helpful--button - (if (trace-is-traced helpful--sym) - "Disable tracing" - "Enable tracing") - 'helpful-trace-button - 'symbol helpful--sym))) + (helpful--make-tracing-button helpful--sym))) (when (and (or can-edebug can-trace) @@ -1163,21 +1201,12 @@ state of the current symbol." (insert "\n")) (when can-disassemble - (insert - (helpful--button - "Disassemble" - 'helpful-disassemble-button - 'object helpful--sym))) + (insert (helpful--make-disassemble-button helpful--sym))) (when can-forget (when can-disassemble (insert " ")) - (insert - (helpful--button - "Forget" - 'helpful-forget-button - 'symbol helpful--sym - 'callable-p helpful--callable-p)))) + (insert (helpful--make-forget-button helpful--sym helpful--callable-p)))) (let ((aliases (helpful--aliases helpful--sym helpful--callable-p))) (when (> (length aliases) 1) |
