mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-07-16 15:46:27 +00:00
org-list: new accessor returning type of list
* lisp/org-list.el (org-list-get-list-type): new function. (org-list-parse-list): use new function. * lisp/org-html.el (org-html-export-list-line): use new function. * lisp/org-docbook.el (org-export-docbook-list-line): use new function.
This commit is contained in:
parent
781228183a
commit
cddea8c542
|
@ -1337,14 +1337,14 @@ modifications to buffer. STRUCT is the list structure. PREVS is
|
||||||
the alist of previous items."
|
the alist of previous items."
|
||||||
(let* ((get-type
|
(let* ((get-type
|
||||||
(function
|
(function
|
||||||
;; Return type of list containing element POS, among
|
;; Translate type of list containing POS to "ordered",
|
||||||
;; "ordered", "variable" or "itemized".
|
;; "variable" or "itemized".
|
||||||
(lambda (pos)
|
(lambda (pos struct prevs)
|
||||||
(cond
|
(let ((type (org-list-get-list-type pos struct prevs)))
|
||||||
((string-match "[[:alnum:]]" (org-list-get-bullet pos struct))
|
(cond
|
||||||
"ordered")
|
((eq 'ordered type) "ordered")
|
||||||
((org-list-get-tag pos struct) "variable")
|
((eq 'descriptive type) "variable")
|
||||||
(t "itemized")))))
|
(t "itemized"))))))
|
||||||
(get-closings
|
(get-closings
|
||||||
(function
|
(function
|
||||||
;; Return list of all items and sublists ending at POS, in
|
;; Return list of all items and sublists ending at POS, in
|
||||||
|
@ -1364,7 +1364,7 @@ the alist of previous items."
|
||||||
(mapc (lambda (e)
|
(mapc (lambda (e)
|
||||||
(let* ((lastp (= (org-list-get-last-item e struct prevs) e))
|
(let* ((lastp (= (org-list-get-last-item e struct prevs) e))
|
||||||
(first-item (org-list-get-list-begin e struct prevs))
|
(first-item (org-list-get-list-begin e struct prevs))
|
||||||
(type (funcall get-type first-item)))
|
(type (funcall get-type first-item struct prevs)))
|
||||||
;; Ending for every item
|
;; Ending for every item
|
||||||
(org-export-docbook-close-para-maybe)
|
(org-export-docbook-close-para-maybe)
|
||||||
(insert (if (equal type "variable")
|
(insert (if (equal type "variable")
|
||||||
|
@ -1389,7 +1389,7 @@ the alist of previous items."
|
||||||
(firstp (= list-beg pos))
|
(firstp (= list-beg pos))
|
||||||
;; Always refer to first item to determine list type, in
|
;; Always refer to first item to determine list type, in
|
||||||
;; case list is ill-formed.
|
;; case list is ill-formed.
|
||||||
(type (funcall get-type list-beg))
|
(type (funcall get-type list-beg struct prevs))
|
||||||
;; Special variables for ordered lists.
|
;; Special variables for ordered lists.
|
||||||
(order-type (let ((bullet (org-list-get-bullet list-beg struct)))
|
(order-type (let ((bullet (org-list-get-bullet list-beg struct)))
|
||||||
(cond
|
(cond
|
||||||
|
|
|
@ -2395,14 +2395,14 @@ modifications to buffer. STRUCT is the list structure. PREVS is
|
||||||
the alist of previous items."
|
the alist of previous items."
|
||||||
(let* ((get-type
|
(let* ((get-type
|
||||||
(function
|
(function
|
||||||
;; Return type of list containing element POS, among "d",
|
;; Translate type of list containing POS to "d", "o" or
|
||||||
;; "o" or "u".
|
;; "u".
|
||||||
(lambda (pos)
|
(lambda (pos struct prevs)
|
||||||
(cond
|
(let ((type (org-list-get-list-type pos struct prevs)))
|
||||||
((string-match "[[:alnum:]]" (org-list-get-bullet pos struct))
|
(cond
|
||||||
"o")
|
((eq 'ordered type) "o")
|
||||||
((org-list-get-tag pos struct) "d")
|
((eq 'descriptive type) "d")
|
||||||
(t "u")))))
|
(t "u"))))))
|
||||||
(get-closings
|
(get-closings
|
||||||
(function
|
(function
|
||||||
;; Return list of all items and sublists ending at POS, in
|
;; Return list of all items and sublists ending at POS, in
|
||||||
|
@ -2422,7 +2422,7 @@ the alist of previous items."
|
||||||
(mapc (lambda (e)
|
(mapc (lambda (e)
|
||||||
(let* ((lastp (= (org-list-get-last-item e struct prevs) e))
|
(let* ((lastp (= (org-list-get-last-item e struct prevs) e))
|
||||||
(first-item (org-list-get-list-begin e struct prevs))
|
(first-item (org-list-get-list-begin e struct prevs))
|
||||||
(type (funcall get-type first-item)))
|
(type (funcall get-type first-item struct prevs)))
|
||||||
(org-close-par-maybe)
|
(org-close-par-maybe)
|
||||||
;; Ending for every item
|
;; Ending for every item
|
||||||
(org-close-li type)
|
(org-close-li type)
|
||||||
|
@ -2445,7 +2445,7 @@ the alist of previous items."
|
||||||
(firstp (= list-beg pos))
|
(firstp (= list-beg pos))
|
||||||
;; Always refer to first item to determine list type, in
|
;; Always refer to first item to determine list type, in
|
||||||
;; case list is ill-formed.
|
;; case list is ill-formed.
|
||||||
(type (funcall get-type list-beg))
|
(type (funcall get-type list-beg struct prevs))
|
||||||
;; Special variables for ordered lists.
|
;; Special variables for ordered lists.
|
||||||
(order-type (let ((bullet (org-list-get-bullet list-beg struct)))
|
(order-type (let ((bullet (org-list-get-bullet list-beg struct)))
|
||||||
(cond
|
(cond
|
||||||
|
|
|
@ -1389,6 +1389,21 @@ STRUCT is the structure of the list. PREVS is the alist of
|
||||||
previous items. See `org-list-struct-prev-alist'."
|
previous items. See `org-list-struct-prev-alist'."
|
||||||
(org-list-get-item-end (org-list-get-last-item item struct prevs) struct))
|
(org-list-get-item-end (org-list-get-last-item item struct prevs) struct))
|
||||||
|
|
||||||
|
(defun org-list-get-list-type (item struct prevs)
|
||||||
|
"Return the type of the list containing ITEM as a symbol.
|
||||||
|
|
||||||
|
STRUCT is the structure of the list, as returned by
|
||||||
|
`org-list-struct'. PREVS is the alist of previous items. See
|
||||||
|
`org-list-struct-prev-alist'.
|
||||||
|
|
||||||
|
Possible types are `descriptive', `ordered' and `unordered'. The
|
||||||
|
type is determined by the first item of the list."
|
||||||
|
(let ((first (org-list-get-list-begin item struct prevs)))
|
||||||
|
(cond
|
||||||
|
((org-list-get-tag first struct) 'descriptive)
|
||||||
|
((string-match "[[:alnum:]]" (org-list-get-bullet first struct)) 'ordered)
|
||||||
|
(t 'unordered))))
|
||||||
|
|
||||||
(defun org-list-get-nth (n key struct)
|
(defun org-list-get-nth (n key struct)
|
||||||
"Return the Nth value of KEY in STRUCT."
|
"Return the Nth value of KEY in STRUCT."
|
||||||
(nth n (assq key struct)))
|
(nth n (assq key struct)))
|
||||||
|
@ -2501,22 +2516,12 @@ Point is left at list end."
|
||||||
(top (org-list-get-top-point struct))
|
(top (org-list-get-top-point struct))
|
||||||
(bottom (org-list-get-bottom-point struct))
|
(bottom (org-list-get-bottom-point struct))
|
||||||
out
|
out
|
||||||
(get-list-type
|
|
||||||
(function
|
|
||||||
;; determine type of list by getting info on item POS in
|
|
||||||
;; STRUCT.
|
|
||||||
(lambda (pos struct)
|
|
||||||
(cond ((string-match "[[:alnum:]]"
|
|
||||||
(org-list-get-bullet pos struct))
|
|
||||||
'ordered)
|
|
||||||
((org-list-get-tag pos struct) 'descriptive)
|
|
||||||
(t 'unordered)))))
|
|
||||||
(parse-sublist
|
(parse-sublist
|
||||||
(function
|
(function
|
||||||
;; return a list whose car is list type and cdr a list of
|
;; return a list whose car is list type and cdr a list of
|
||||||
;; items' body.
|
;; items' body.
|
||||||
(lambda (e)
|
(lambda (e)
|
||||||
(cons (funcall get-list-type (car e) struct)
|
(cons (org-list-get-list-type (car e) struct prevs)
|
||||||
(mapcar parse-item e)))))
|
(mapcar parse-item e)))))
|
||||||
(parse-item
|
(parse-item
|
||||||
(function
|
(function
|
||||||
|
|
Loading…
Reference in a new issue