Function: org-element--cache-after-change

org-element--cache-after-change is a byte-compiled function defined in org-element.el.gz.

Signature

(org-element--cache-after-change BEG END PRE)

Documentation

Update buffer modifications for current buffer.

BEG, END, and PRE are the beginning and end of the range of changed text, and the length in bytes of the pre-change text replaced by that range. See after-change-functions for more information.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
(defun org-element--cache-after-change (beg end pre)
  "Update buffer modifications for current buffer.
BEG, END, and PRE are the beginning and end of the range of changed
text, and the length in bytes of the pre-change text replaced by
that range.  See `after-change-functions' for more information."
  (org-with-base-buffer nil
    (when (org-element--cache-active-p t)
      (when (not (eq org-element--cache-change-tic (buffer-chars-modified-tick)))
        (org-element--cache-log-message "After change")
        (org-element--cache-before-change beg end)
        ;; If beg is right after spaces in front of an element, we
        ;; risk affecting previous element, so move beg to bol, making
        ;; sure that we capture preceding element.
        (setq beg (save-excursion
                    (goto-char beg)
                    (cl-incf pre (- beg (line-beginning-position)))
                    (line-beginning-position)))
        ;; Store synchronization request.
        (let ((offset (- end beg pre)))
          ;; We must preserve match data when called as `after-change-functions'.
          (save-match-data
            (org-element--cache-submit-request beg (- end offset) offset)))
        ;; Activate a timer to process the request during idle time.
        (org-element--cache-set-timer (current-buffer))))))