diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 172da3db1e0..616286a817d 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -2591,6 +2591,16 @@ 'radio-button :off "( )" :off-glyph "radio") +(defcustom widget-radio-face-from-state nil + "How to fontify the label of a radio button. +If non-nil, use `widget-inactive' face for the label if the +radio-button-choice widget is inactive and default face if it is active. +If nil, use the default face for the label only if the associated radio +button is pressed, otherwise use `widget-inactive' face." + :type 'boolean + :group 'widget-faces + :version "30.1") + (defun widget-radio-button-notify (widget _child &optional event) ;; Tell daddy. (widget-apply (widget-get widget :parent) :action widget event)) @@ -2653,8 +2663,9 @@ widget-radio-add-item (widget-create-child-value widget type value) (widget-create-child widget type))) - (unless chosen - (widget-apply child :deactivate))) + (unless widget-radio-face-from-state + (unless chosen + (widget-apply child :deactivate)))) (t (error "Unknown escape `%c'" escape))))) ;; Update properties. @@ -2706,12 +2717,14 @@ widget-radio-value-set (match (and (not found) (widget-apply current :match value)))) (widget-value-set button match) - (if match - (progn - (widget-value-set current value) - (widget-apply current :activate)) - (widget-apply current :deactivate)) - (setq found (or found match)))))) + (if widget-radio-face-from-state + (when match (widget-value-set current value)) + (if match + (progn + (widget-value-set current value) + (widget-apply current :activate)) + (widget-apply current :deactivate))) + (setq found (or found match)))))) (defun widget-radio-validate (widget) ;; Valid if we have made a valid choice. @@ -2734,10 +2747,12 @@ widget-radio-action (let* ((button (widget-get current :button))) (cond ((eq child button) (widget-value-set button t) - (widget-apply current :activate)) + (unless widget-radio-face-from-state + (widget-apply current :activate))) ((widget-value button) (widget-value-set button nil) - (widget-apply current :deactivate))))))) + (unless widget-radio-face-from-state + (widget-apply current :deactivate)))))))) ;; Pass notification to parent. (widget-apply widget :notify child event))