Function: widget-checklist-add-item
widget-checklist-add-item is a byte-compiled function defined in
wid-edit.el.gz.
Signature
(widget-checklist-add-item WIDGET TYPE CHOSEN)
Documentation
Create checklist item in WIDGET of type TYPE.
If the item is checked, CHOSEN is a cons whose cdr is the value.
Source Code
;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget-checklist-add-item (widget type chosen)
"Create checklist item in WIDGET of type TYPE.
If the item is checked, CHOSEN is a cons whose cdr is the value."
(and (widget--should-indent-p)
(widget-get widget :indent)
(insert-char ?\s (widget-get widget :indent)))
(widget-specify-insert
(let* ((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))
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 'checkbox
:value (not (null chosen))
button-args)))
((eq escape ?v)
(setq child
(cond ((not chosen)
(let* ((child (widget-create-child widget type))
(from (widget-get child :from))
(to (widget-get child :to)))
(widget-specify-unselected child from to)
child))
((widget-inline-p type t)
(widget-create-child-value
widget type (cdr chosen)))
(t
(widget-specify-selected child)
(widget-create-child-value
widget type (car (cdr chosen)))))))
(t
(error "Unknown escape `%c'" escape)))))
;; Update properties.
(and button child (widget-put child :button button))
(and button (widget-put widget :buttons (cons button buttons)))
(and child (widget-put widget :children (cons child children))))))