Function: widget-convert
widget-convert is an autoloaded and byte-compiled function defined in
wid-edit.el.gz.
Signature
(widget-convert TYPE &rest ARGS)
Documentation
Convert TYPE to a widget without inserting it in the buffer.
The optional ARGS are additional keyword arguments.
Source Code
;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
;;;###autoload
(defun widget-convert (type &rest args)
"Convert TYPE to a widget without inserting it in the buffer.
The optional ARGS are additional keyword arguments."
;; Don't touch the type.
(let* ((widget (if (symbolp type)
(list type)
(copy-sequence type)))
(current widget)
done
(keys args))
;; First set the :args keyword.
(while (cdr current) ;Look in the type.
(if (and (keywordp (cadr current))
;; If the last element is a keyword,
;; it is still the :args element,
;; even though it is a keyword.
(cddr current))
(if (eq (cadr current) :args)
;; If :args is explicitly specified, obey it.
(setq current nil)
;; Some other irrelevant keyword.
(setq current (cdr (cdr current))))
(setcdr current (list :args (cdr current)))
(setq current nil)))
(while (and args (not done)) ;Look in ARGS.
(cond ((eq (car args) :args)
;; Handle explicit specification of :args.
(setq args (cadr args)
done t))
((keywordp (car args))
(setq args (cddr args)))
(t (setq done t))))
(when done
(widget-put widget :args args))
;; Then Convert the widget.
(setq type widget)
(while type
(let ((convert-widget (plist-get (cdr type) :convert-widget)))
(if convert-widget
(setq widget (funcall convert-widget widget))))
(setq type (get (car type) 'widget-type)))
;; Finally set the keyword args.
(while keys
(let ((next (nth 0 keys)))
(if (keywordp next)
(progn
(widget-put widget next (nth 1 keys))
(setq keys (nthcdr 2 keys)))
(setq keys nil))))
;; Convert the :value to internal format.
(if (widget-member widget :value)
(widget-put widget
:value (widget-apply widget
:value-to-internal
(widget-get widget :value))))
;; Return the newly create widget.
widget))