diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-05-01 15:06:57 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-05-01 15:06:57 +0200 |
commit | 9ab45860a64e0da416ddd4ec2735162fab5d4ff4 (patch) | |
tree | 0d908859807e9a1a31152b21286834fbcd0bbdf5 | |
parent | ede4b999b85f1ff430fb5caa425a6935de3bfd57 (diff) | |
parent | 80eb69b6484aee61779aeb6ad59efca939b7a460 (diff) | |
download | org-mode-9ab45860a64e0da416ddd4ec2735162fab5d4ff4.tar.gz |
Merge branch 'maint'
-rw-r--r-- | lisp/org-list.el | 4 | ||||
-rw-r--r-- | testing/lisp/test-org-list.el | 102 |
2 files changed, 55 insertions, 51 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el index 6e8cf4c..ba92217 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -1602,8 +1602,8 @@ bullets between START and END." (funcall change-bullet-maybe item) (cond ;; First item indented but not parent: error - ((and (not prev) (< parent start)) - (error "Cannot indent the first item of a list")) + ((and (not prev) (or (not parent) (< parent start))) + (user-error "Cannot indent the first item of a list")) ;; First item and parent indented: keep same ;; parent. ((not prev) (funcall set-assoc cell)) diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index 93c6680..019e257 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -220,69 +220,73 @@ (ert-deftest test-org-list/indent-item () "Test `org-indent-item' specifications." - ;; 1. Error when not at an item. + ;; Error when not at an item. (org-test-with-temp-text "Paragraph." (should-error (org-indent-item))) - ;; 2. Error when trying to move first item of a list. - (org-test-with-temp-text " + ;; Error when trying to move first item of a list. + (should-error + (org-test-with-temp-text " - Item 1 - Item 2" - (forward-line) - (should-error (org-indent-item))) - ;; 3. Indent a single item, not its children. - (org-test-with-temp-text " + (forward-line) + (org-indent-item))) + (should-error + (org-test-with-temp-text " - Item 1 -- Item 2 - - Item 2.1" - (search-forward "- Item 2") - (let (org-list-demote-modify-bullet) (org-indent-item)) - (should (equal (buffer-string) - " +- Item 2" + (forward-line) + (let ((org-list-automatic-rules nil)) (org-indent-item)))) + ;; Indent a single item, not its children. + (should + (equal " - Item 1 - Item 2 - - Item 2.1"))) - ;; 4. Follow `org-list-demote-modify-bullet' specifications. - ;; - ;; 4.1. With unordered lists. - (org-test-with-temp-text " + - Item 2.1" + (org-test-with-temp-text " - Item 1 -- Item 2" - (search-forward "- Item 2") - (let ((org-list-demote-modify-bullet '(("-" . "+")))) (org-indent-item)) - (should (equal (buffer-string) - " +- Item 2<point> + - Item 2.1" + (let (org-list-demote-modify-bullet) (org-indent-item)) + (buffer-string)))) + ;; Follow `org-list-demote-modify-bullet' specifications. + (should + (equal " - Item 1 - + Item 2"))) - ;; 4.2. and ordered lists. - (org-test-with-temp-text " + + Item 2" + (org-test-with-temp-text " +- Item 1 +- Item 2<point>" + (let ((org-list-demote-modify-bullet '(("-" . "+")))) + (org-indent-item)) + (buffer-string)))) + (should + (equal " 1. Item 1 -2. Item 2" - (search-forward "2. Item 2") - (let ((org-plain-list-ordered-item-terminator t) - (org-list-demote-modify-bullet '(("1." . "+")))) - (org-indent-item)) - (should (equal (buffer-string) - " + + Item 2" + (org-test-with-temp-text " 1. Item 1 - + Item 2"))) - ;; 5. When a region is selected, indent every item within. - (org-test-with-temp-text " -- Item 1 -- Item 2 -- Item 3 -" - (search-forward "- Item 2") - (beginning-of-line) - (transient-mark-mode 1) - (push-mark (point) t t) - (goto-char (point-max)) - (let (org-list-demote-modify-bullet) (org-indent-item)) - (should (equal (buffer-string) - " +2. Item 2<point>" + (let ((org-plain-list-ordered-item-terminator t) + (org-list-demote-modify-bullet '(("1." . "+")))) + (org-indent-item)) + (buffer-string)))) + ;; When a region is selected, indent every item within. + (should + (equal " - Item 1 - Item 2 - Item 3 -")))) +" + (org-test-with-temp-text " +- Item 1 +<point>- Item 2 +- Item 3 +" + (transient-mark-mode 1) + (push-mark (point) t t) + (goto-char (point-max)) + (let (org-list-demote-modify-bullet) (org-indent-item)) + (buffer-string))))) (ert-deftest test-org-list/indent-item-tree () "Test `org-indent-item-tree' specifications." |