diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2010-08-08 22:28:53 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2010-09-01 19:05:53 +0200 |
commit | d726f924dd9d3162aff3148b1e7ab50a3c3a44da (patch) | |
tree | b2ca5ba6b6d82f812984764f77af13a66dd2ba88 | |
parent | a2a72f38fa8cd5f13c7ddf18d91c8c76f4fdad69 (diff) | |
download | org-mode-d726f924dd9d3162aff3148b1e7ab50a3c3a44da.tar.gz |
Fix bug when moving a *-list at column 0. Docstrings modifications.
* org-list.el (org-indent-item-tree): when moving top item of a *-list
to column 0, only the first item had its bullet changed to -. It now
changes all items of the top-level list, as expected.
-rw-r--r-- | lisp/org-list.el | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el index ed12d41..4aaaa3d 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -789,9 +789,10 @@ bullet string and bullet counter, if any." A structure is an alist where key is point of item and values are, in that order, indentation, bullet string and value of -counter if any. The structure contains every list and sublist -that has items between BEGIN and END and their common parent, if -any. +counter, if any. A structure contains every list and sublist that +has items between BEGIN and END along with their common ancestor. +If no such ancestor can be found, the function will add a virtual +ancestor at position 0. If OUTDENT is non-nil, it will also grab all of the parent list and the grand-parent. Setting OUTDENT to t is mandatory when next @@ -811,8 +812,7 @@ change is an outdent." (while (and (org-search-backward-unenclosed org-item-beginning-re top t) (>= (org-get-indentation) ind-min)) (setq pre-list (cons (org-list-struct-assoc-at-point) pre-list))) - ;; Now get the parent, if any. If not, add a virtual - ;; ancestor at position 0. + ;; Now get the parent. If none, add a virtual ancestor (if (< (org-get-indentation) ind-min) (setq pre-list (cons (org-list-struct-assoc-at-point) pre-list)) (setq pre-list (cons (list 0 (org-get-indentation) "" nil) pre-list))) @@ -836,8 +836,7 @@ change is an outdent." extended))))) (defun org-list-struct-origins (struct) - "Return an alist where key is item's position and value parent's. -Common ancestor of structure is, as a convention, at position 0." + "Return an alist where key is item's position and value parent's." (let* ((struct-rev (reverse struct)) (prev-item (lambda (item) (car (nth 1 (member (assq item struct) struct-rev))))) (get-origins @@ -1116,9 +1115,12 @@ children. Return t if successful." (top-ind (nth 1 beg-item))) (if (< (+ top-ind offset) 0) (error "Cannot outdent beyond margin") + ;; Change bullet if necessary (when (and (= (+ top-ind offset) 0) (string-match "*" (nth 2 beg-item))) (setcdr beg-item (list (nth 1 beg-item) (org-list-bullet-string "-")))) - (mapc '(lambda (item) (setcdr item (cons (+ (nth 1 item) offset) (cddr item)))) struct) + ;; Shift ancestor + (let ((anc (car struct))) (setcdr anc (list (+ (nth 1 anc) offset) "" nil))) + (org-list-struct-fix-struct struct origins) (org-list-struct-apply-struct struct)))) ;; Forbidden move ((and (< arg 0) |