org-element: Fix parsing of bold objects at the beginning of a headline

* lisp/org-element.el (org-element-context): Fix parsing of bold
  objects at the beginning of a headline.
* testing/lisp/test-org-element.el (test-org-element/context): Add
  test.
This commit is contained in:
Nicolas Goaziou 2014-03-12 09:05:50 +01:00
parent ffc60fd494
commit cb22a0355f
2 changed files with 9 additions and 3 deletions

View File

@ -4868,8 +4868,8 @@ Providing it allows for quicker computation."
;; their title. ;; their title.
((memq type '(headline inlinetask)) ((memq type '(headline inlinetask))
(goto-char (org-element-property :begin element)) (goto-char (org-element-property :begin element))
(skip-chars-forward "* ") (skip-chars-forward "*")
(if (and (>= origin (point)) (< origin (line-end-position))) (if (and (> origin (point)) (< origin (line-end-position)))
(narrow-to-region (point) (line-end-position)) (narrow-to-region (point) (line-end-position))
(throw 'objects-forbidden element))) (throw 'objects-forbidden element)))
;; At a paragraph, a table-row or a verse block, objects are ;; At a paragraph, a table-row or a verse block, objects are

View File

@ -3076,7 +3076,13 @@ Paragraph \\alpha."
(org-test-with-temp-text "Some *text with _underline_ text*" (org-test-with-temp-text "Some *text with _underline_ text*"
(progn (progn
(search-forward "under") (search-forward "under")
(org-element-type (org-element-context (org-element-at-point)))))))) (org-element-type (org-element-context (org-element-at-point)))))))
;; Special case: bold object at the beginning of a headline.
(should
(eq 'bold
(org-test-with-temp-text "* *bold*"
(search-forward "bo")
(org-element-type (org-element-context))))))
(provide 'test-org-element) (provide 'test-org-element)