org-element: Fix bug in cache

* lisp/org-element.el (org-element--cache-sync): Modifying blank lines
  at the end of a list or a footnote definition no longer corrupt
  cache.
This commit is contained in:
Nicolas Goaziou 2013-11-04 19:28:07 +01:00
parent 8255286e22
commit 8403332dbc
1 changed files with 17 additions and 2 deletions

View File

@ -5038,8 +5038,23 @@ removed from the cache."
((>= key beg) (remhash key org-element--cache))
;; Preserve any element ending before BEG. If it
;; overlaps the BEG-END area, remove it.
(t (or (< (org-element-property :end (car value)) beg)
(remhash key org-element--cache)))))
(t
(when (let ((element (car value)))
(or (>= (org-element-property :end element) beg)
;; Special case: footnote definitions and
;; plain lists can end with blank lines.
;; Modifying those can also alter last
;; element inside. We must therefore
;; remove these elements from cache.
(let ((parent
(org-element-property :parent element)))
(and (memq (org-element-type parent)
'(footnote-definition plain-list))
(>= (org-element-property :end parent) beg)
(= (org-element-property :contents-end
parent)
(org-element-property :end element))))))
(remhash key org-element--cache)))))
org-element--cache)
;; Signal cache as up-to-date.
(org-element--cache-cancel-changes))))))