@@ -625,6 +625,24 @@ overrides that to include previously opened buffers."
625625 (eval-expression expr))
626626 (helpful-update)))
627627
628+ (define-button-type 'helpful-reset-button
629+ 'action #'helpful--reset
630+ 'symbol nil
631+ 'buffer nil
632+ 'follow-link t
633+ 'help-echo " Reset the value of this symbol" )
634+
635+ (defun helpful--reset (button )
636+ " Reset the value of this symbol to its standard value."
637+ (let* ((sym (button-get button 'symbol ))
638+ (buf (button-get button 'buffer ))
639+ (standard-value (car (helpful--original-value sym))))
640+ (save-current-buffer
641+ (when buf
642+ (set-buffer buf))
643+ (set sym standard-value))
644+ (helpful-update)))
645+
628646(define-button-type 'helpful-view-literal-button
629647 'action #'helpful--view-literal
630648 'help-echo " Toggle viewing as a literal" )
@@ -1823,6 +1841,14 @@ POSITION-HEADS takes the form ((123 (defun foo)) (456 (defun bar)))."
18231841 'symbol sym
18241842 'buffer buffer))
18251843
1844+ (defun helpful--make-reset-button (sym buffer )
1845+ " Make a reset button for SYM in BUFFER."
1846+ (helpful--button
1847+ " Reset"
1848+ 'helpful-reset-button
1849+ 'symbol sym
1850+ 'buffer buffer))
1851+
18261852(defun helpful--make-toggle-literal-button ()
18271853 " Make set button for SYM in BUFFER."
18281854 (helpful--button
@@ -2315,6 +2341,8 @@ state of the current symbol."
23152341 (when (memq (helpful--sym-value helpful--sym helpful--associated-buffer) '(nil t ))
23162342 (insert (helpful--make-toggle-button helpful--sym helpful--associated-buffer) " " ))
23172343 (insert (helpful--make-set-button helpful--sym helpful--associated-buffer))
2344+ (when (helpful--original-value-differs-p helpful--sym)
2345+ (insert " " (helpful--make-reset-button helpful--sym helpful--associated-buffer)))
23182346 (when (custom-variable-p helpful--sym)
23192347 (insert " " (helpful--make-customize-button helpful--sym)))))
23202348
0 commit comments