Function: allout-decorate-item-icon
allout-decorate-item-icon is a byte-compiled function defined in
allout-widgets.el.gz.
Signature
(allout-decorate-item-icon ITEM-WIDGET)
Documentation
Add item icon glyph and distinctive bullet text properties to ITEM-WIDGET.
Source Code
;; Defined in /usr/src/emacs/lisp/allout-widgets.el.gz
;;;_ > allout-decorate-item-icon (item-widget)
(defun allout-decorate-item-icon (item-widget)
"Add item icon glyph and distinctive bullet text properties to ITEM-WIDGET."
(when (not (widget-get item-widget :is-container))
(let* ((icon-start (widget-get item-widget :icon-start))
(icon-end (widget-get item-widget :icon-end))
(bullet (widget-get item-widget :bullet))
(use-bullet bullet)
(was-bullet (widget-get item-widget :was-bullet))
(distinctive (allout-distinctive-bullet bullet))
(distinctive-start (widget-get item-widget :distinctive-start))
(distinctive-end (widget-get item-widget :distinctive-end))
(does-encrypt (widget-get item-widget :does-encrypt))
(is-encrypted (and does-encrypt (widget-get item-widget
:is-encrypted)))
(expanded (widget-get item-widget :expanded))
(has-subitems (widget-get item-widget :has-subitems))
(inhibit-read-only t)
icon-state)
(when (not (and (equal (widget-get item-widget :was-expanded) expanded)
(equal (widget-get item-widget :was-has-subitems)
has-subitems)
(equal (widget-get item-widget :was-does-encrypt)
does-encrypt)
(equal (widget-get item-widget :was-is-encrypted)
is-encrypted)))
(setq icon-state
(cond (does-encrypt (if is-encrypted
'locked-encrypted
'unlocked-encrypted))
(expanded 'opened)
(has-subitems 'closed)
(t 'empty)))
(put-text-property icon-start (1+ icon-start)
'display (allout-fetch-icon-image icon-state))
(widget-put item-widget :was-expanded expanded)
(widget-put item-widget :was-has-subitems has-subitems)
(widget-put item-widget :was-does-encrypt does-encrypt)
(widget-put item-widget :was-is-encrypted is-encrypted)
;; preserve as a widget property to track last known:
(widget-put item-widget :icon-state icon-state)
;; preserve as a text property to track undo:
(put-text-property icon-start icon-end :icon-state icon-state))
(allout-item-element-span-is item-widget :icon-span
icon-start icon-end)
(when (not (string= was-bullet bullet))
(cond ((not distinctive)
;; XXX we strip the prior properties without even checking if
;; the prior bullet was distinctive, because the widget
;; provisions to convey that info is disappearing, sigh.
(remove-text-properties icon-end (1+ icon-end) '(display nil))
(setq distinctive-start icon-end distinctive-end icon-end)
(widget-put item-widget :distinctive-start distinctive-start)
(widget-put item-widget :distinctive-end distinctive-end))
((not (string= bullet allout-numbered-bullet))
(setq distinctive-start icon-end distinctive-end (+ icon-end 1)))
(does-encrypt
(setq distinctive-start icon-end distinctive-end (+ icon-end 1)))
(t
(goto-char icon-end)
(looking-at "[0-9]+")
(setq use-bullet (buffer-substring icon-end (match-end 0)))
(setq distinctive-start icon-end
distinctive-end (match-end 0))))
(put-text-property distinctive-start distinctive-end 'display
use-bullet)
(widget-put item-widget :was-bullet bullet)
(widget-put item-widget :distinctive-start distinctive-start)
(widget-put item-widget :distinctive-end distinctive-end)))))