forked from mirrors/org-mode
Added a rule for indentation and improved reordering.
* org-list.el (org-indent-item-tree): If indent rule is activated, it should be impossible to outdent an item having children without moving its subtree. Improved reordering of lists modified by cycling indentation.
This commit is contained in:
parent
19372845f9
commit
0a14598575
|
@ -802,16 +802,26 @@ If NO-SUBTREE is set, only indent the item itself, not its children."
|
||||||
(cond
|
(cond
|
||||||
;; Going to a negative column is nonsensical.
|
;; Going to a negative column is nonsensical.
|
||||||
((< (+ delta ind) 0) (error "Cannot outdent beyond margin"))
|
((< (+ delta ind) 0) (error "Cannot outdent beyond margin"))
|
||||||
;; Do not indent before top-item, unless point is at top-item.
|
;; Apply indent rules if activated.
|
||||||
((and (< (+ delta ind) origin-ind)
|
((cdr (assq 'indent org-list-automatic-rules))
|
||||||
(/= (point-at-bol) (org-list-top-point)))
|
(cond
|
||||||
(error "Cannot outdent beyond top level item"))
|
;; If at top-point move the whole list. Moreover, if *-list
|
||||||
((and firstp (> delta 0) (/= (point-at-bol) (org-list-top-point)))
|
;; is going to column 0, change bullet to "-".
|
||||||
(error "Cannot indent the beginning of a sublist"))
|
((= (point-at-bol) (org-list-top-point))
|
||||||
;; If *-list is going to column 0, prevent mixing items and
|
(when (and (= (+ delta ind) 0) (equal bullet "*")) (org-fix-bullet-type "-"))
|
||||||
;; headings by changing bullet to "-".
|
(setq end (set-marker org-last-indent-end-marker (org-list-bottom-point))))
|
||||||
((and (= (+ delta ind) 0) (equal bullet "*"))
|
;; Do not indent before top-item.
|
||||||
(org-fix-bullet-type "-")))
|
((< (+ delta ind) origin-ind)
|
||||||
|
(error "Cannot outdent beyond top level item"))
|
||||||
|
;; Do not indent the first item of a list.
|
||||||
|
((and firstp (> delta 0))
|
||||||
|
(error "Cannot indent the beginning of a sublist"))
|
||||||
|
;; Do not outdent item that has children without moving subtree.
|
||||||
|
((and (/= (save-excursion (org-end-of-item-text-before-children))
|
||||||
|
(save-excursion (org-end-of-item)))
|
||||||
|
(< delta 0)
|
||||||
|
no-subtree)
|
||||||
|
(error "Cannot outdent an item having children without moving subtree")))))
|
||||||
;; Proceed to reindentation.
|
;; Proceed to reindentation.
|
||||||
(while (< (point) end)
|
(while (< (point) end)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
|
@ -821,11 +831,17 @@ If NO-SUBTREE is set, only indent the item itself, not its children."
|
||||||
(beginning-of-line 2)))
|
(beginning-of-line 2)))
|
||||||
(org-fix-bullet-type
|
(org-fix-bullet-type
|
||||||
(and (> arg 0)
|
(and (> arg 0)
|
||||||
(not firstp)
|
|
||||||
(cdr (assoc bullet org-list-demote-modify-bullet))))
|
(cdr (assoc bullet org-list-demote-modify-bullet))))
|
||||||
|
;; Reorder lists that might have changed
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(beginning-of-line 0)
|
(beginning-of-line 0)
|
||||||
(ignore-errors (org-beginning-of-item))
|
(ignore-errors (org-beginning-of-item))
|
||||||
|
(org-maybe-renumber-ordered-list))
|
||||||
|
(save-excursion
|
||||||
|
(org-end-of-item-text-before-children)
|
||||||
|
(org-maybe-renumber-ordered-list))
|
||||||
|
(save-excursion
|
||||||
|
(org-end-of-item-list)
|
||||||
(org-maybe-renumber-ordered-list))))
|
(org-maybe-renumber-ordered-list))))
|
||||||
|
|
||||||
(defun org-item-indent-positions ()
|
(defun org-item-indent-positions ()
|
||||||
|
@ -882,8 +898,8 @@ Assumes cursor in item line."
|
||||||
(if (eq last-command 'org-cycle-item-indentation)
|
(if (eq last-command 'org-cycle-item-indentation)
|
||||||
(condition-case nil
|
(condition-case nil
|
||||||
(progn (org-outdent-item 1)
|
(progn (org-outdent-item 1)
|
||||||
(if (equal org-tab-ind-state (org-get-indentation))
|
(when (equal org-tab-ind-state (org-get-indentation))
|
||||||
(org-outdent-item 1))
|
(org-outdent-item 1))
|
||||||
(end-of-line))
|
(end-of-line))
|
||||||
(error
|
(error
|
||||||
(progn
|
(progn
|
||||||
|
|
Loading…
Reference in New Issue