Function: widget-choice-prompt-value
widget-choice-prompt-value is a byte-compiled function defined in
wid-edit.el.gz.
Signature
(widget-choice-prompt-value WIDGET PROMPT VALUE UNBOUND)
Documentation
Make a choice.
Source Code
;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget-choice-prompt-value (widget prompt value _unbound)
"Make a choice."
(let ((args (widget-get widget :args))
(completion-ignore-case (widget-get widget :case-fold))
current choices old)
;; Find the first arg that matches VALUE.
(let ((look args))
(while look
(if (widget-apply (car look) :match value)
(setq old (car look)
look nil)
(setq look (cdr look)))))
;; Find new choice.
(setq current
(cond ((= (length args) 0)
nil)
((= (length args) 1)
(nth 0 args))
((and (= (length args) 2)
(memq old args))
(if (eq old (nth 0 args))
(nth 1 args)
(nth 0 args)))
(t
(while args
(setq current (car args)
args (cdr args))
(setq choices
(cons (cons (widget-apply current :menu-tag-get)
current)
choices)))
(let ((val (completing-read prompt choices nil t)))
(if (stringp val)
(let ((try (try-completion val choices)))
(when (stringp try)
(setq val try))
(cdr (assoc val choices)))
nil)))))
(if current
(widget-prompt-value current prompt nil t)
value)))