helpful

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

commit e2806f532c7fb3ab320404163905d48f0b24a83a
parent 464e6e76c6905b7a4dddfd3c06a6a2953f974ddd
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Sun,  4 Jun 2017 12:15:33 +0100

Move tools to a separate section and improve forget

Ask for user confirmation before forgetting, and don't show macros as
'forget function'.

Diffstat:
Mhelpful.el | 37++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/helpful.el b/helpful.el @@ -81,23 +81,25 @@ This allows us to distinguish strings from symbols." (define-button-type 'helpful-forget-button 'action #'helpful--forget + 'symbol nil 'follow-link t 'help-echo "Unbind this function") ;; TODO: it would be nice to optionally delete the source code too. -(defun helpful--forget (_button) +(defun helpful--forget (button) "Unbind the current symbol." - (when (functionp helpful--sym) - (fmakunbound helpful--sym)) - (makunbound helpful--sym) - (message "Forgot function %s" helpful--sym) - (kill-buffer (current-buffer))) - -(defun helpful--forget-button () + (let* ((sym (button-get button 'symbol)) + (kind (if (functionp sym) "function" "macro"))) + (when (yes-or-no-p (format "Forget %s %s" kind sym)) + (fmakunbound sym) + (message "Forgot %s %s" kind sym) + (kill-buffer (current-buffer))))) + +(defun helpful--forget-button (sym) "Return a button that unbinds the current symbol" (with-temp-buffer (insert-text-button - "Forget function" + "Forget" :type 'helpful-forget-button) (buffer-string))) @@ -426,6 +428,14 @@ state of the current symbol." (or (helpful--format-properties helpful--sym) "No properties.") + (helpful--heading "\n\nDebugging Tools\n") + (if (helpful--primitive-p helpful--sym) + "" + (concat + (helpful--disassemble-button) + "\n")) + (helpful--forget-button helpful--sym) + (helpful--heading "\n\nSource Code\n") (if source-path (concat @@ -445,14 +455,7 @@ state of the current symbol." source (if (helpful--primitive-p helpful--sym) 'c-mode)) - (helpful--syntax-highlight (helpful--pretty-print source))) - "\n" - (if (helpful--primitive-p helpful--sym) - "" - (concat - (helpful--disassemble-button) - " ")) - (helpful--forget-button)) + (helpful--syntax-highlight (helpful--pretty-print source)))) (goto-char start-pos))) (defun helpful--skip-advice (docstring)