Function: tree-widget-value-create
tree-widget-value-create is a byte-compiled function defined in
tree-widget.el.gz.
Signature
(tree-widget-value-create TREE)
Documentation
Create the TREE tree-widget.
Source Code
;; Defined in /usr/src/emacs/lisp/tree-widget.el.gz
(defun tree-widget-value-create (tree)
"Create the TREE tree-widget."
(let* ((node (tree-widget-node tree))
(flags (widget-get tree :tree-widget--guide-flags))
(indent (widget-get tree :indent))
;; Setup widget's image support. Looking up for images, and
;; setting widgets' :tag-glyph is done here, to allow us to
;; dynamically change the image theme.
(widget-image-enable (tree-widget-use-image-p))
children buttons)
(and indent (not (widget-get tree :parent))
(insert-char ?\ indent))
(if (widget-get tree :open)
;;;; Expanded node.
(let ((args (widget-get tree :args))
(guide (widget-get tree :guide))
(nohandle-guide (widget-get tree :nohandle-guide))
(noguide (widget-get tree :no-guide))
(endguide (widget-get tree :end-guide))
(handle (widget-get tree :handle))
(nohandle (widget-get tree :no-handle))
(guidi (tree-widget-find-image "guide"))
(nohandle-guidi (tree-widget-find-image "nohandle-guide"))
(noguidi (tree-widget-find-image "no-guide"))
(endguidi (tree-widget-find-image "end-guide"))
(handli (tree-widget-find-image "handle"))
(nohandli (tree-widget-find-image "no-handle")))
;; Request children at run time, when requested.
(when (and (widget-get tree :expander)
(widget-apply tree :expander-p))
(setq args (mapcar #'widget-convert
(widget-apply tree :expander)))
(widget-put tree :args args))
;; Defer the node widget creation after icon creation.
(widget-put tree :node (widget-convert node))
;; Create the icon widget for the expanded tree.
(push (widget-create-child-and-convert
tree (widget-get tree (if args :open-icon :empty-icon))
;; Pass the node widget to child.
:node (widget-get tree :node))
buttons)
;; Create the tree node widget.
(push (widget-create-child tree (widget-get tree :node))
children)
;; Update the icon :node with the created node widget.
(widget-put (car buttons) :node (car children))
;; Create the tree children.
(while args
(setq node (car args)
args (cdr args))
(and indent (insert-char ?\ indent))
;; Insert guide lines elements from previous levels.
(dolist (f (reverse flags))
(widget-create-child-and-convert
tree (if f nohandle-guide noguide)
:tag-glyph (if f nohandle-guidi noguidi))
(widget-create-child-and-convert
tree nohandle :tag-glyph nohandli))
;; Insert guide line element for this level.
(widget-create-child-and-convert
tree (if args guide endguide)
:tag-glyph (if args guidi endguidi))
;; Insert the node handle line
(widget-create-child-and-convert
tree handle :tag-glyph handli)
(if (tree-widget-p node)
;; Create a sub-tree node.
(push (widget-create-child-and-convert
tree node :tree-widget--guide-flags
(cons (if args t) flags))
children)
;; Create the icon widget for a leaf node.
(push (widget-create-child-and-convert
tree (widget-get tree :leaf-icon)
;; At this point the node widget isn't yet created.
:node (setq node (widget-convert
node :tree-widget--guide-flags
(cons (if args t) flags)))
:tree-widget--leaf-flag t)
buttons)
;; Create the leaf node widget.
(push (widget-create-child tree node) children)
;; Update the icon :node with the created node widget.
(widget-put (car buttons) :node (car children)))))
;;;; Collapsed node.
;; Defer the node widget creation after icon creation.
(widget-put tree :node (widget-convert node))
;; Create the icon widget for the collapsed tree.
(push (widget-create-child-and-convert
tree (widget-get tree :close-icon)
;; Pass the node widget to child.
:node (widget-get tree :node))
buttons)
;; Create the tree node widget.
(push (widget-create-child tree (widget-get tree :node))
children)
;; Update the icon :node with the created node widget.
(widget-put (car buttons) :node (car children)))
;; Save widget children and buttons. The tree-widget :node child
;; is the first element in :children.
(widget-put tree :children (nreverse children))
(widget-put tree :buttons buttons)))