org-element: Fix cache

* lisp/org-element.el (org-element--cache-after-change): Preserve
  match data.

Thanks to Matt Lundin for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/87871
This commit is contained in:
Nicolas Goaziou 2014-06-23 12:28:11 +02:00
parent def0361b7b
commit 69773248c5
1 changed files with 35 additions and 36 deletions

View File

@ -5449,15 +5449,14 @@ text. See `before-change-functions' for more information."
BEG and END 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."
(let ((inhibit-quit t))
(when (org-element--cache-active-p)
(org-with-wide-buffer
(goto-char beg)
(beginning-of-line)
(save-match-data
(let ((top (point))
(bottom (save-excursion (goto-char end) (line-end-position))))
(org-with-limited-levels
(save-match-data
;; Determine if modified area needs to be extended,
;; according to both previous and current state. We make
;; a special case for headline editing: if a headline is
@ -5484,12 +5483,12 @@ that range. See `after-change-functions' for more information."
(point)))
(setq bottom (progn (goto-char bottom)
(if (outline-next-heading) (1- (point))
(point)))))))
(point))))))
;; Store synchronization request.
(let ((offset (- end beg pre)))
(org-element--cache-submit-request top (- bottom offset) offset))))
(org-element--cache-submit-request top (- bottom offset) offset)))))
;; Activate a timer to process the request during idle time.
(org-element--cache-set-timer (current-buffer)))))
(org-element--cache-set-timer (current-buffer))))
(defun org-element--cache-for-removal (beg end offset)
"Return first element to remove from cache.