diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-06-01 21:38:15 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-06-01 21:38:15 +0200 |
commit | d8b983b85a4f657a67d628f430c53e504cfa2183 (patch) | |
tree | 91747f462427972dad867abf46a734ce312e4ec2 | |
parent | 45565503dce50f0e563dd4386ca4b46f9eefe428 (diff) | |
download | org-mode-d8b983b85a4f657a67d628f430c53e504cfa2183.tar.gz |
org-element: Fix failing "plain-list-parser" test
* lisp/org-element.el (org-element--list-struct): Fix failing
"plain-list-parser" test.
* testing/lisp/test-org-element.el: Update test.
-rw-r--r-- | lisp/org-element.el | 15 | ||||
-rw-r--r-- | testing/lisp/test-org-element.el | 26 |
2 files changed, 21 insertions, 20 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el index 463f696..5f2e700 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -1147,9 +1147,10 @@ CONTENTS is the contents of the element." ;;;; Plain List (defun org-element--list-struct (limit) -;; Return structure of list at point. Internal function. See -;; `org-list-struct' for details. + ;; Return structure of list at point. Internal function. See + ;; `org-list-struct' for details. (let ((case-fold-search t) + (top-ind limit) (item-re (org-item-re)) (drawers-re (concat ":\\(" (mapconcat 'regexp-quote org-drawers "\\|") @@ -1178,6 +1179,7 @@ CONTENTS is the contents of the element." ((looking-at item-re) (let ((ind (save-excursion (skip-chars-forward " \t") (current-column)))) + (setq top-ind (min top-ind ind)) (while (and items (<= ind (nth 1 (car items)))) (let ((item (pop items))) (setcar (nthcdr 6 item) (point)) @@ -1209,13 +1211,12 @@ CONTENTS is the contents of the element." ;; At some text line. Check if it ends any previous item. (t (let ((ind (progn (skip-chars-forward " \t") (current-column)))) + (when (<= ind top-ind) + (skip-chars-backward " \r\t\n") + (forward-line)) (while (<= ind (nth 1 (car items))) (let ((item (pop items))) - (setcar (nthcdr 6 item) - (if items (line-beginning-position) - (skip-chars-backward " \r\t\n") - (forward-line) - (point))) + (setcar (nthcdr 6 item) (line-beginning-position)) (push item struct) (unless items (throw 'exit (sort struct 'car-less-than-car)))))) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 029b161..bed9633 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -1494,24 +1494,24 @@ e^{i\\pi}+1=0 (ert-deftest test-org-element/plain-list-parser () "Test `plain-list' parser." - (should - (org-test-with-temp-text "- item" - (org-element-map (org-element-parse-buffer) 'plain-list 'identity))) + (org-test-with-temp-text "- item" + (should (org-element-map (org-element-parse-buffer) 'plain-list 'identity))) ;; Blank lines after the list only belong to outer plain list. - (org-test-with-temp-text " + (should + (equal + '(t t) + (org-test-with-temp-text " - outer - inner Outside list" - (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 "^$"))))) + (let ((endings (org-element-map (org-element-parse-buffer) 'plain-list + (lambda (pl) (org-element-property :end pl))))) + (list + ;; Move to ending of outer list. + (progn (goto-char (car endings)) (looking-at "Outside list")) + ;; Move to ending of inner list. + (progn (goto-char (nth 1 endings)) (looking-at "^$")))))))) ;;;; Planning |