summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2010-07-20 11:06:35 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2010-09-01 19:05:48 +0200
commit42f82d1bad20dcf00304c146e2e15bebad5fe4f9 (patch)
tree75afc2b88ffb142ed5033593c39834b7b1ec8b40
parent8241e9b652404cadaba82780ea8dd94d329fd7e5 (diff)
downloadorg-mode-42f82d1bad20dcf00304c146e2e15bebad5fe4f9.tar.gz
Descriptions items shouldn't be numbered.
* org-list.el (org-cycle-list-bullet): prevent description items from being numbered. String argument is also recognized now, as long as it is a valid bullet.
-rw-r--r--lisp/org-list.el44
1 files changed, 24 insertions, 20 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 6e74e13..53bc86b 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -975,36 +975,40 @@ doing the renumbering."
(defun org-cycle-list-bullet (&optional which)
"Cycle through the different itemize/enumerate bullets.
-This cycle the entire list level through the sequence:
+This cycle the entire list level through nnthe sequence:
- `-' -> `+' -> `*' -> `1.' -> `1)'
+ `-' -> `+' -> `*' -> `1.' -> `1)'
-If WHICH is a string, use that as the new bullet. If WHICH is an integer,
-0 means `-', 1 means `+' etc."
+If WHICH is a valid string, use that as the new bullet. If WHICH
+is an integer, 0 means `-', 1 means `+' etc."
(interactive "P")
(org-preserve-lc
- (let* ((current (progn
- (org-beginning-of-item-list)
- (org-at-item-p)
- (match-string 0)))
- (prevp (eq which 'previous))
+ (let* ((bullet (progn (org-beginning-of-item-list)
+ (org-get-bullet)))
+ (current (cond
+ ((string-match "\\." bullet) "1.")
+ ((string-match ")" bullet) "1)")
+ (t bullet)))
+ ;; Description items cannot be numbered
+ (bullet-list (if (org-at-description-p)
+ '("-" "+" "*")
+ '("-" "+" "*" "1." "1)")))
+ ;; *-bullets are not allowed at column 0
+ (bullet-list (if (looking-at "\\S-")
+ (remove "*" bullet-list)
+ bullet-list))
+ (item-pos (member current bullet-list))
(new (cond
((and (numberp which)
- (nth (1- which) '("-" "+" "*" "1." "1)"))))
- ((string-match "-" current) (if prevp "1)" "+"))
- ((string-match "\\+" current)
- (if prevp "-" (if (looking-at "\\S-") "1." "*")))
- ((string-match "\\*" current) (if prevp "+" "1."))
- ((string-match "\\." current)
- (if prevp (if (looking-at "\\S-") "+" "*") "1)"))
- ((string-match ")" current) (if prevp "1." "-"))
- (t (error "This should not happen"))))
+ (nth (mod which (length bullet-list)) bullet-list)))
+ ((member which bullet-list) which)
+ ((and item-pos (cdr item-pos)) (cadr item-pos))
+ (t "-")))
(old (and (looking-at "\\([ \t]*\\)\\(\\S-+\\)")
(match-string 2))))
(replace-match (concat "\\1" new))
(org-shift-item-indentation (- (length new) (length old)))
- (org-fix-bullet-type)
- (org-maybe-renumber-ordered-list))))
+ (org-fix-bullet-type))))
;;; Checkboxes