Skip to content

Commit

Permalink
Refactor the trace + update code to a new function
Browse files Browse the repository at this point in the history
  • Loading branch information
nbfalcon committed Mar 12, 2021
1 parent b6b64e1 commit f32a9d8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions helpful.el
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,15 @@ or disable if already enabled."
(untrace-function sym)
(trace-function sym)))

(defun helpful--trace-1 (sym)
"Toggle tracing for SYM and update the *helpful* buffer."
(helpful--toggle-tracing sym)
(helpful-update))

(defun helpful--trace (button)
"Toggle tracing for the current symbol."
(let ((sym (button-get button 'symbol)))
(helpful--toggle-tracing sym))
(helpful-update))
(helpful--trace-1 sym)))

(define-button-type 'helpful-navigate-button
'action #'helpful--navigate
Expand Down Expand Up @@ -1165,8 +1169,7 @@ buffer."
(helpful--ensure)
(unless helpful--callable-p
(user-error "Cannot trace a variable"))
(helpful--toggle-tracing helpful--sym)
(helpful-update))
(helpful--trace-1 helpful--sym))

(defun helpful-set-value ()
(interactive)
Expand Down

0 comments on commit f32a9d8

Please sign in to comment.