@@ -638,6 +638,24 @@ overrides that to include previously opened buffers."
638638 (eval-expression expr))
639639 (helpful-update)))
640640
641+ (define-button-type 'helpful-reset-button
642+ 'action #'helpful--reset
643+ 'symbol nil
644+ 'buffer nil
645+ 'follow-link t
646+ 'help-echo " Reset the value of this symbol" )
647+
648+ (defun helpful--reset (button )
649+ " Reset the value of this symbol to its standard value."
650+ (let* ((sym (button-get button 'symbol ))
651+ (buf (button-get button 'buffer ))
652+ (standard-value (car (helpful--original-value sym))))
653+ (save-current-buffer
654+ (when buf
655+ (set-buffer buf))
656+ (set sym standard-value))
657+ (helpful-update)))
658+
641659(define-button-type 'helpful-view-literal-button
642660 'action #'helpful--view-literal
643661 'help-echo " Toggle viewing as a literal" )
@@ -1844,6 +1862,14 @@ POSITION-HEADS takes the form ((123 (defun foo)) (456 (defun bar)))."
18441862 'symbol sym
18451863 'buffer buffer))
18461864
1865+ (defun helpful--make-reset-button (sym buffer )
1866+ " Make a reset button for SYM in BUFFER."
1867+ (helpful--button
1868+ " Reset"
1869+ 'helpful-reset-button
1870+ 'symbol sym
1871+ 'buffer buffer))
1872+
18471873(defun helpful--make-toggle-literal-button ()
18481874 " Make set button for SYM in BUFFER."
18491875 (helpful--button
@@ -2393,6 +2419,8 @@ state of the current symbol."
23932419 (when (memq (helpful--sym-value helpful--sym helpful--associated-buffer) '(nil t ))
23942420 (insert (helpful--make-toggle-button helpful--sym helpful--associated-buffer) " " ))
23952421 (insert (helpful--make-set-button helpful--sym helpful--associated-buffer))
2422+ (when (helpful--original-value-differs-p helpful--sym)
2423+ (insert " " (helpful--make-reset-button helpful--sym helpful--associated-buffer)))
23962424 (when (custom-variable-p helpful--sym)
23972425 (insert " " (helpful--make-customize-button helpful--sym)))))
23982426
0 commit comments