Function: custom-icon-value-create
custom-icon-value-create is a byte-compiled function defined in
cus-edit.el.gz.
Signature
(custom-icon-value-create WIDGET)
Documentation
Here is where you edit the icon's specification.
Source Code
;; Defined in /usr/src/emacs/lisp/cus-edit.el.gz
(defun custom-icon-value-create (widget)
"Here is where you edit the icon's specification."
(custom-load-widget widget)
(unless (widget-get widget :custom-form)
(widget-put widget :custom-form custom-variable-default-form))
(let* ((buttons (widget-get widget :buttons))
(children (widget-get widget :children))
(form (widget-get widget :custom-form))
(symbol (widget-get widget :value))
(tag (widget-get widget :tag))
(type '(repeat
(list (choice (const :tag "Images" image)
(const :tag "Colorful Emojis" emoji)
(const :tag "Monochrome Symbols" symbol)
(const :tag "Text Only" text))
(repeat string)
plist)))
(prefix (widget-get widget :custom-prefix))
(last (widget-get widget :custom-last))
(style (widget-get widget :custom-style))
(value (let ((shown-value (widget-get widget :shown-value)))
(cond (shown-value
(car shown-value))
(t (icon-complete-spec symbol nil t)))))
(state (or (widget-get widget :custom-state)
(if (memq (custom-icon-state symbol value)
(widget-get widget :hidden-states))
'hidden))))
;; Transform the spec into something that agrees with the type.
(setq value
(mapcar
(lambda (elem)
(list (car elem)
(icon-spec-values elem)
(icon-spec-keywords elem)))
value))
;; Now we can create the child widget.
(cond ((eq custom-buffer-style 'tree)
(insert prefix (if last " `--- " " |--- "))
(push (widget-create-child-and-convert
widget 'custom-browse-variable-tag)
buttons)
(insert " " tag "\n")
(widget-put widget :buttons buttons))
((eq state 'hidden)
;; Indicate hidden value.
(push (widget-create-child-and-convert
widget 'custom-visibility
:help-echo "Show the value of this option."
:on-glyph "down"
:on "Hide"
:off-glyph "right"
:off "Show Value"
:action 'custom-toggle-hide-icon
nil)
buttons)
(insert " ")
(push (widget-create-child-and-convert
widget 'item
:format "%{%t%} "
:sample-face 'custom-variable-tag
:tag tag
:parent widget)
buttons))
(t
;; Edit mode.
(push (widget-create-child-and-convert
widget 'custom-visibility
:help-echo "Hide or show this option."
:on "Hide"
:off "Show"
:on-glyph "down"
:off-glyph "right"
:action 'custom-toggle-hide-icon
t)
buttons)
(insert " ")
(let* ((format (widget-get type :format))
tag-format)
(unless (string-match ":\\s-?" format)
(error "Bad format"))
(setq tag-format (substring format 0 (match-end 0)))
(push (widget-create-child-and-convert
widget 'item
:format tag-format
:action 'custom-tag-action
:help-echo "Change specs of this face."
:mouse-down-action 'custom-tag-mouse-down-action
:button-face 'custom-variable-button
:sample-face 'custom-variable-tag
:tag tag)
buttons)
(push (widget-create-child-and-convert
widget type
:value value)
children))))
(unless (eq custom-buffer-style 'tree)
(unless (eq (preceding-char) ?\n)
(widget-insert "\n"))
;; Create the magic button.
(unless (eq style 'simple)
(let ((magic (widget-create-child-and-convert
widget 'custom-magic nil)))
(widget-put widget :custom-magic magic)
(push magic buttons)))
(widget-put widget :buttons buttons)
;; Insert documentation.
(widget-put widget :documentation-indent 3)
(unless (and (eq style 'simple)
(eq state 'hidden))
(widget-add-documentation-string-button
widget :visibility-widget 'custom-visibility))
;; Update the rest of the properties.
(widget-put widget :custom-form form)
(widget-put widget :children children)
;; Now update the state.
(if (eq state 'hidden)
(widget-put widget :custom-state state)
(custom-icon-state-set widget))
;; See also.
(unless (eq state 'hidden)
(when (eq (widget-get widget :custom-level) 1)
(custom-add-parent-links widget))
(custom-add-see-also widget)))))