Function: widget-choice-action
widget-choice-action is a byte-compiled function defined in
wid-edit.el.gz.
Signature
(widget-choice-action WIDGET &optional EVENT)
Source Code
;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget-choice-action (widget &optional event)
;; Make a choice.
(let ((args (widget-get widget :args))
(old (widget-get widget :choice))
(tag (widget-apply widget :menu-tag-get))
(completion-ignore-case (widget-get widget :case-fold))
this-explicit
current choices)
;; Remember old value.
(if (and old (not (widget-apply widget :validate)))
(let* ((external (widget-value widget))
(internal (widget-apply old :value-to-internal external)))
(widget-put old :value internal)))
;; Find new choice.
(setq current
(cond ((= (length args) 0)
nil)
((= (length args) 1)
(nth 0 args))
((and widget-choice-toggle
(= (length args) 2)
(memq old args))
(nth (if (eq old (nth 0 args)) 1 0)
args))
(t
(dolist (current args)
(setq choices
(cons (cons (widget-apply current :menu-tag-get)
current)
choices)))
(setq this-explicit t)
(widget-choose tag (reverse choices) event))))
(when current
;; If this was an explicit user choice, record the choice,
;; so that widget-choice-value-create will respect it.
(when this-explicit
(widget-put widget :explicit-choice current))
(widget-value-set widget (widget-default-get current))
(widget-setup)
(widget-apply widget :notify widget event)))
(run-hook-with-args 'widget-edit-functions widget))