@@ -647,6 +647,24 @@ overrides that to include previously opened buffers."
647647 (eval-expression expr))
648648 (helpful-update)))
649649
650+ (define-button-type 'helpful-reset-button
651+ 'action #'helpful--reset
652+ 'symbol nil
653+ 'buffer nil
654+ 'follow-link t
655+ 'help-echo " Reset the value of this symbol" )
656+
657+ (defun helpful--reset (button )
658+ " Reset the value of this symbol to its standard value."
659+ (let* ((sym (button-get button 'symbol ))
660+ (buf (button-get button 'buffer ))
661+ (standard-value (car (helpful--original-value sym))))
662+ (save-current-buffer
663+ (when buf
664+ (set-buffer buf))
665+ (set sym standard-value))
666+ (helpful-update)))
667+
650668(define-button-type 'helpful-view-literal-button
651669 'action #'helpful--view-literal
652670 'help-echo " Toggle viewing as a literal" )
@@ -1857,6 +1875,14 @@ POSITION-HEADS takes the form ((123 (defun foo)) (456 (defun bar)))."
18571875 'symbol sym
18581876 'buffer buffer))
18591877
1878+ (defun helpful--make-reset-button (sym buffer )
1879+ " Make a reset button for SYM in BUFFER."
1880+ (helpful--button
1881+ " Reset"
1882+ 'helpful-reset-button
1883+ 'symbol sym
1884+ 'buffer buffer))
1885+
18601886(defun helpful--make-toggle-literal-button ()
18611887 " Make set button for SYM in BUFFER."
18621888 (helpful--button
@@ -2406,6 +2432,8 @@ state of the current symbol."
24062432 (when (memq (helpful--sym-value helpful--sym helpful--associated-buffer) '(nil t ))
24072433 (insert (helpful--make-toggle-button helpful--sym helpful--associated-buffer) " " ))
24082434 (insert (helpful--make-set-button helpful--sym helpful--associated-buffer))
2435+ (when (helpful--original-value-differs-p helpful--sym)
2436+ (insert " " (helpful--make-reset-button helpful--sym helpful--associated-buffer)))
24092437 (when (custom-variable-p helpful--sym)
24102438 (insert " " (helpful--make-customize-button helpful--sym)))))
24112439
0 commit comments