Function: widget-radio-add-item
widget-radio-add-item is a byte-compiled function defined in
wid-edit.el.gz.
Signature
(widget-radio-add-item WIDGET TYPE)
Documentation
Add to radio widget WIDGET a new radio button item of type TYPE.
Source Code
;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget-radio-add-item (widget type)
"Add to radio widget WIDGET a new radio button item of type TYPE."
;; (setq type (widget-convert type))
(and (widget--should-indent-p)
(widget-get widget :indent)
(insert-char ?\s (widget-get widget :indent)))
(widget-specify-insert
(let* ((value (widget-get widget :value))
(children (widget-get widget :children))
(buttons (widget-get widget :buttons))
(button-args (or (widget-get type :sibling-args)
(widget-get widget :button-args)))
(from (point))
(chosen (and (null (widget-get widget :choice))
(widget-apply type :match value)))
child button)
(insert (widget-get widget :entry-format))
(goto-char from)
;; Parse % escapes in format.
(while (re-search-forward "%\\([bv%]\\)" nil t)
(let ((escape (char-after (match-beginning 1))))
(delete-char -2)
(cond ((eq escape ?%)
(insert ?%))
((eq escape ?b)
(setq button (apply #'widget-create-child-and-convert
widget 'radio-button
:value (not (null chosen))
button-args)))
((eq escape ?v)
(setq child (if chosen
(widget-create-child-value
widget type value)
(widget-create-child widget type)))
(if chosen
(widget-specify-selected child)
(let ((from (widget-get child :from))
(to (widget-get child :to)))
(widget-specify-unselected child from to))))
(t
(error "Unknown escape `%c'" escape)))))
;; Update properties.
(when chosen
(widget-put widget :choice type))
(when button
(widget-put child :button button)
(widget-put widget :buttons (nconc buttons (list button))))
(when child
(widget-put widget :children (nconc children (list child))))
child)))