Function: org-element--cache-shift-positions
org-element--cache-shift-positions is a byte-compiled function defined
in org-element.el.gz.
Signature
(org-element--cache-shift-positions ELEMENT OFFSET &optional PROPS)
Documentation
Shift ELEMENT properties relative to buffer positions by OFFSET.
Properties containing buffer positions are :begin, :end,
:contents-begin, :contents-end and :structure. When
optional argument PROPS is a list of keywords, only shift
properties provided in that list.
Properties are modified by side-effect.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
(defsubst org-element--cache-shift-positions (element offset &optional props)
"Shift ELEMENT properties relative to buffer positions by OFFSET.
Properties containing buffer positions are `:begin', `:end',
`:contents-begin', `:contents-end' and `:structure'. When
optional argument PROPS is a list of keywords, only shift
properties provided in that list.
Properties are modified by side-effect."
;; Shift `:structure' property for the first plain list only: it
;; is the only one that really matters and it prevents from
;; shifting it more than once.
(when (and (not (zerop offset))
(or (not props) (memq :structure props))
(org-element-type-p element 'plain-list)
(not (org-element-type-p
;; Cached elements cannot have deferred `:parent'.
(org-element-property-raw :parent element)
'item)))
(let ((structure (org-element-property :structure element)))
(dolist (item structure)
(cl-incf (car item) offset)
(cl-incf (nth 6 item) offset))))
;; Clear :fragile cache when contents is changed.
(when props (org-element-put-property element :fragile-cache nil))
;; Do not use loop for inline expansion to work during compile time.
(unless (zerop offset)
(when (or (not props) (memq :begin props))
(cl-incf (org-element-begin element) offset))
(when (or (not props) (memq :end props))
(cl-incf (org-element-end element) offset))
(when (or (not props) (memq :post-affiliated props))
(cl-incf (org-element-post-affiliated element) offset))
(when (and (or (not props) (memq :contents-begin props))
(org-element-contents-begin element))
(cl-incf (org-element-contents-begin element) offset))
(when (and (or (not props) (memq :contents-end props))
(org-element-contents-end element))
(cl-incf (org-element-contents-end element) offset))
(when (and (or (not props) (memq :robust-begin props))
(org-element-property :robust-begin element))
(cl-incf (org-element-property :robust-begin element) offset))
(when (and (or (not props) (memq :robust-end props))
(org-element-property :robust-end element))
(cl-incf (org-element-property :robust-end element) offset))))