Function: allout-item-actual-position
allout-item-actual-position is a byte-compiled function defined in
allout-widgets.el.gz.
Signature
(allout-item-actual-position ITEM-WIDGET FIELD)
Documentation
Return ITEM-WIDGET FIELD position taking item displacement into account.
Source Code
;; Defined in /usr/src/emacs/lisp/allout-widgets.el.gz
;;;_ > allout-item-actual-position (item-widget field)
(defun allout-item-actual-position (item-widget field)
"Return ITEM-WIDGET FIELD position taking item displacement into account."
;; The item's sub-element positions (:icon-end, :body-start, etc) are
;; accurate when the item is parsed, but some offsets from the start
;; drift with text added in the body.
;;
;; Rather than reparse an item with every change (inefficient), or derive
;; every position from a distinct field marker/overlay (prohibitive as
;; the number of items grows), we use the displacement tracking of the
;; :span-overlay's markers, against the registered :from or :body-end
;; (depending on whether the requested field value is before or after the
;; item body), to bias the registered values.
;;
;; This is not necessary/useful when the item is being decorated, because
;; that always must be preceded by a fresh item parse.
(if (not (eq field :body-end))
(widget-get item-widget :from)
(let* ((span-overlay (widget-get item-widget :span-overlay))
(body-end-position (widget-get item-widget :body-end))
(ref-marker-position (and span-overlay
(overlay-end span-overlay)))
(offset (and body-end-position span-overlay
(- (or ref-marker-position 0)
body-end-position))))
(+ (widget-get item-widget field) (or offset 0)))))