summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2013-07-21 15:51:14 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2013-07-21 15:51:14 +0200
commitb4a8ec9321860d65f17c9fd348728a71d126a02b (patch)
tree5271e0620c36c546b02ea3862ae7a745766c9a75
parent21dd83661b5d4fb7cae90d69e610bdb832972673 (diff)
downloadorg-mode-b4a8ec9321860d65f17c9fd348728a71d126a02b.tar.gz
org-element: Fix infloop when parsing a list at the end of buffer
* lisp/org-element.el (org-element-plain-list-parser): Fix infloop when parsing a list at the end of buffer, if buffer doesn't end at a line beginning. * testing/lisp/test-org-element.el: Add test.
-rw-r--r--lisp/org-element.el3
-rw-r--r--testing/lisp/test-org-element.el12
2 files changed, 9 insertions, 6 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index c08ccb1..3cf87b2 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1178,8 +1178,7 @@ Assume point is at the beginning of the list."
(unless (bolp) (forward-line))
(point)))
(end (progn (skip-chars-forward " \r\t\n" limit)
- (skip-chars-backward " \t")
- (if (bolp) (point) (line-end-position)))))
+ (if (= (point) limit) limit (line-beginning-position)))))
;; Return value.
(list 'plain-list
(nconc
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 5cfe95a..f384aaa 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1503,15 +1503,19 @@ e^{i\\pi}+1=0
- inner
Outside list"
- (let ((endings (org-element-map
- (org-element-parse-buffer) 'plain-list
- (lambda (pl) (org-element-property :end pl)))))
+ (let ((endings (org-element-map (org-element-parse-buffer) 'plain-list
+ (lambda (pl) (org-element-property :end pl)))))
;; Move to ending of outer list.
(goto-char (car endings))
(should (looking-at "Outside list"))
;; Move to ending of inner list.
(goto-char (nth 1 endings))
- (should (looking-at "^$")))))
+ (should (looking-at "^$"))))
+ ;; Correctly compute end of list if it doesn't end at a line
+ ;; beginning.
+ (should
+ (org-test-with-temp-text "- list\n \n "
+ (= (org-element-property :end (org-element-at-point)) (point-max)))))
;;;; Planning