diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-04-06 00:37:49 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-04-06 00:37:49 +0200 |
commit | 1ba8413b0a0077cb5d3ecedcd97a228c08bf0eb9 (patch) | |
tree | 43145257788925c68e01c05c4d20fb760505d1d3 | |
parent | 789ddf155af9744c3ab6758397f0561e149a5da9 (diff) | |
download | org-mode-1ba8413b0a0077cb5d3ecedcd97a228c08bf0eb9.tar.gz |
org-element: Fix cache bug
* lisp/org-element.el (org-element--cache-for-removal): Be more
careful when altering a properties drawer.
* testing/lisp/test-org-element.el (test-org-element/cache): Add test.
-rw-r--r-- | lisp/org-element.el | 21 | ||||
-rw-r--r-- | testing/lisp/test-org-element.el | 9 |
2 files changed, 23 insertions, 7 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el index eaf5b8c..ef1e703 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -5451,13 +5451,20 @@ changes." (let ((up before) (robust-flag t)) (while up - (if (and (memq (org-element-type up) - '(center-block drawer dynamic-block - quote-block special-block)) - (let ((cbeg (org-element-property :contents-begin up))) - (and cbeg - (<= cbeg beg) - (> (org-element-property :contents-end up) end)))) + (if (let ((type (org-element-type up))) + (and (or (memq type '(center-block dynamic-block quote-block + special-block)) + ;; Drawers named "PROPERTIES" are probably + ;; a properties drawer being edited. Force + ;; parsing to check if editing is over. + (and (eq type 'drawer) + (not (string= + (org-element-property :drawer-name up) + "PROPERTIES")))) + (let ((cbeg (org-element-property :contents-begin up))) + (and cbeg + (<= cbeg beg) + (> (org-element-property :contents-end up) end))))) ;; UP is a robust greater element containing changes. ;; We only need to extend its ending boundaries. (org-element--cache-shift-positions diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 50e0da4..964d13c 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -3488,6 +3488,15 @@ Text (search-forward "# ") (delete-char -1) (search-backward "Para1") + (org-element-type (org-element-at-point)))))) + ;; Corner case: watch out drawers named "PROPERTIES" as they are + ;; fragile, unlike to other drawers. + (should + (eq 'node-property + (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:A<point>\n:END:" + (let ((org-element-use-cache t)) + (org-element-at-point) + (insert "+:") (org-element-type (org-element-at-point))))))) |