summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-08-25 15:26:33 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-08-25 15:27:01 +0200
commitb4604d2833372fcbd6cffe4018d8e3cc98f6ae33 (patch)
tree7c16b886c0327d073a28063474e6729fac0efab6
parenteaa1dee2d035c22d077170605c34b5594552e476 (diff)
downloadorg-mode-b4604d2833372fcbd6cffe4018d8e3cc98f6ae33.tar.gz
org-element: Fix filling bug in a list with affiliated keyword
* lisp/org-element.el (org-element-paragraph-parser): Fix parsing of paragraph at the beginning of an item. * testing/lisp/test-org-element.el: Add test.
-rw-r--r--lisp/org-element.el14
-rw-r--r--testing/lisp/test-org-element.el15
2 files changed, 24 insertions, 5 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index f0e1a0f..f2c87de 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1736,9 +1736,15 @@ containing `:begin', `:end', `:contents-begin' and
Assume point is at the beginning of the paragraph."
(save-excursion
- (let* ((contents-begin (point))
- (keywords (org-element--collect-affiliated-keywords))
- (begin (car keywords))
+ (let* (;; INNER-PAR-P is non-nil when paragraph is at the
+ ;; beginning of an item or a footnote reference. In that
+ ;; case, we mustn't look for affiliated keywords since they
+ ;; belong to the container.
+ (inner-par-p (/= (point-at-bol) (point)))
+ (contents-begin (point))
+ (keywords (unless inner-par-p
+ (org-element--collect-affiliated-keywords)))
+ (begin (if inner-par-p contents-begin (car keywords)))
(before-blank
(let ((case-fold-search t))
(end-of-line)
@@ -1797,7 +1803,7 @@ Assume point is at the beginning of the paragraph."
;; If paragraph has no affiliated keywords, it may not begin
;; at beginning of line if it starts an item.
(nconc
- (list :begin (if (cadr keywords) begin contents-begin)
+ (list :begin begin
:end end
:contents-begin contents-begin
:contents-end contents-end
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 63faca1..7271cd3 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1168,7 +1168,20 @@ e^{i\\pi}+1=0
(org-test-with-temp-text "#+BEGIN: \nParagraph"
(let ((elem (org-element-at-point)))
(and (eq (org-element-type elem) 'paragraph)
- (= (point-max) (org-element-property :end elem)))))))
+ (= (point-max) (org-element-property :end elem))))))
+ ;; Include incomplete latex environments.
+ (should
+ (org-test-with-temp-text "\begin{equation}\nParagraph"
+ (let ((elem (org-element-at-point)))
+ (and (eq (org-element-type elem) 'paragraph)
+ (= (point-max) (org-element-property :end elem))))))
+ ;; Do not steal affiliated keywords from container.
+ (should
+ (org-test-with-temp-text "#+ATTR_LATEX: test\n- item 1"
+ (let ((elem (progn (search-forward "item") (org-element-at-point))))
+ (and (eq (org-element-type elem) 'paragraph)
+ (not (org-element-property :attr_latex elem))
+ (/= (org-element-property :begin elem) 1))))))
;;;; Plain List