Function: org-list-struct-indent
org-list-struct-indent is a byte-compiled function defined in
org-list.el.gz.
Signature
(org-list-struct-indent START END STRUCT PARENTS PREVS)
Documentation
Indent items between positions START and END.
STRUCT is the list structure. PARENTS is the alist of parents
and PREVS is the alist of previous items, returned by,
respectively, org-list-parents-alist and
org-list-prevs-alist.
START is included and END excluded.
STRUCT may be modified if org-list-demote-modify-bullet matches
bullets between START and END.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-list.el.gz
(defun org-list-struct-indent (start end struct parents prevs)
"Indent items between positions START and END.
STRUCT is the list structure. PARENTS is the alist of parents
and PREVS is the alist of previous items, returned by,
respectively, `org-list-parents-alist' and
`org-list-prevs-alist'.
START is included and END excluded.
STRUCT may be modified if `org-list-demote-modify-bullet' matches
bullets between START and END."
(let* (acc
(set-assoc (lambda (cell) (push cell acc) cell))
(ind
(lambda (cell)
(let* ((item (car cell))
(parent (cdr cell)))
(cond
;; Item not yet in zone: keep association.
((< item start) cell)
((>= item end)
;; Item out of zone: follow associations in ACC.
(let ((convert (assq parent acc)))
(if convert (cons item (cdr convert)) cell)))
(t
;; Item is in zone...
(let ((prev (org-list-get-prev-item item struct prevs)))
;; Check if bullet needs to be changed.
(pcase (assoc (let ((b (org-list-get-bullet item struct))
(case-fold-search nil))
(cond ((string-match "[A-Z]\\." b) "A.")
((string-match "[A-Z])" b) "A)")
((string-match "[a-z]\\." b) "a.")
((string-match "[a-z])" b) "a)")
((string-match "[0-9]\\." b) "1.")
((string-match "[0-9])" b) "1)")
(t (org-trim b))))
org-list-demote-modify-bullet)
(`(,_ . ,bullet)
(org-list-set-bullet
item struct (org-list-bullet-string bullet)))
(_ nil))
(cond
;; First item indented but not parent: error
((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))
;; Previous item not indented: reparent to it.
((< prev start) (funcall set-assoc (cons item prev)))
;; Previous item indented: reparent like it.
(t
(funcall set-assoc
(cons item (cdr (assq prev acc)))))))))))))
(mapcar ind parents)))