summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2014-11-18 18:44:46 (GMT)
committer Nicolas Goaziou <mail@nicolasgoaziou.fr>2014-11-18 18:44:46 (GMT)
commit4f31b68e8f19848bfe580524119a67ebfd7a6972 (patch)
tree7d2b98f139407d32437a1c293e86ff1cea2c5eda
parent59111b77efad2583e432a86479ccf8d175077e8e (diff)
downloadorg-mode-maint.zip
org-mode-maint.tar.gz
org-element: Fix 'search failed ":"' errormaint
* lisp/org-element.el (org-element-context): Fix 'search failed ":"' error when point is on a blank line after a keyword. * testing/lisp/test-org-element.el (test-org-element/context): Add tests.
-rw-r--r--lisp/org-element.el2
-rw-r--r--testing/lisp/test-org-element.el13
2 files changed, 11 insertions, 4 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index eb8ff41..0ec86cf 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4887,7 +4887,7 @@ Providing it allows for quicker computation."
(if (not (member (org-element-property :key element)
org-element-document-properties))
(throw 'objects-forbidden element)
- (beginning-of-line)
+ (goto-char (org-element-property :begin element))
(search-forward ":")
(if (and (>= origin (point)) (< origin (line-end-position)))
(narrow-to-region (point) (line-end-position))
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 5e8f0ff..b86531c 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -3087,9 +3087,16 @@ Text
;; Find objects in document keywords.
(should
(eq 'macro
- (org-test-with-temp-text "#+DATE: {{{macro}}}"
- (progn (search-forward "{")
- (org-element-type (org-element-context))))))
+ (org-test-with-temp-text "#+DATE: <point>{{{macro}}}"
+ (org-element-type (org-element-context)))))
+ (should-not
+ (eq 'macro
+ (org-test-with-temp-text "#+DATE: {{{macro}}}\n<point>"
+ (org-element-type (org-element-context)))))
+ (should-not
+ (eq 'macro
+ (org-test-with-temp-text "#+RANDOM_KEYWORD: <point>{{{macro}}}"
+ (org-element-type (org-element-context)))))
;; Do not find objects in table rules.
(should
(eq 'table-row