summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2019-02-18 23:15:58 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2019-02-18 23:38:13 +0100
commit6b8fb446b6e04b6b488c90113c28acba7d4e1917 (patch)
tree19c61154dfbdaf504c7360ff5f34b60c5d4095ec
parent08cb207b388bc7d2e87e3e4ddead727c1b927681 (diff)
downloadorg-mode-6b8fb446b6e04b6b488c90113c28acba7d4e1917.tar.gz
org-list: Fix `org-list-demote-modify-bullet' with alpha bullets
* lisp/org-list.el (org-list-struct-indent): Match case-sensitively against current bullet in order the tell the difference between "a." and "A.". * testing/lisp/test-org-list.el (test-org-list/indent-item): Add test.
-rw-r--r--lisp/org-list.el31
-rw-r--r--testing/lisp/test-org-list.el12
2 files changed, 27 insertions, 16 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 1c636dd..727ec67 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -1569,22 +1569,21 @@ bullets between START and END."
(let* (acc
(set-assoc (lambda (cell) (push cell acc) cell))
(change-bullet-maybe
- (function
- (lambda (item)
- (let ((new-bul-p
- (cdr (assoc
- ;; Normalize ordered bullets.
- (let ((bul (org-trim
- (org-list-get-bullet item struct))))
- (cond ((string-match "[A-Z]\\." bul) "A.")
- ((string-match "[A-Z])" bul) "A)")
- ((string-match "[a-z]\\." bul) "a.")
- ((string-match "[a-z])" bul) "a)")
- ((string-match "[0-9]\\." bul) "1.")
- ((string-match "[0-9])" bul) "1)")
- (t bul)))
- org-list-demote-modify-bullet))))
- (when new-bul-p (org-list-set-bullet item struct new-bul-p))))))
+ (lambda (item)
+ (let ((new-bul
+ (cdr (assoc
+ ;; Normalize ordered bullets.
+ (let ((bul (org-list-get-bullet item struct))
+ (case-fold-search nil))
+ (cond ((string-match "[A-Z]\\." bul) "A.")
+ ((string-match "[A-Z])" bul) "A)")
+ ((string-match "[a-z]\\." bul) "a.")
+ ((string-match "[a-z])" bul) "a)")
+ ((string-match "[0-9]\\." bul) "1.")
+ ((string-match "[0-9])" bul) "1)")
+ (t (org-trim bul))))
+ org-list-demote-modify-bullet))))
+ (when new-bul (org-list-set-bullet item struct new-bul)))))
(ind
(lambda (cell)
(let* ((item (car cell))
diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el
index bbd6ee7..c3864ca 100644
--- a/testing/lisp/test-org-list.el
+++ b/testing/lisp/test-org-list.el
@@ -270,6 +270,18 @@
(org-list-demote-modify-bullet '(("1." . "+"))))
(org-indent-item))
(buffer-string))))
+ (should
+ (equal "
+a. Item 1
+ - Item 2"
+ (org-test-with-temp-text "
+a. Item 1
+b. Item 2<point>"
+ (let ((org-plain-list-ordered-item-terminator t)
+ (org-list-allow-alphabetical t)
+ (org-list-demote-modify-bullet '(("A." . "a.") ("a." . "-"))))
+ (org-indent-item))
+ (buffer-string))))
;; When a region is selected, indent every item within.
(should
(equal "