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.
This commit is contained in:
Nicolas Goaziou 2013-07-21 15:51:14 +02:00
parent 21dd83661b
commit b4a8ec9321
2 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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