summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2011-01-17 19:30:04 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2011-02-18 12:45:10 +0100
commitcddea8c5422d7679db7ab2ef7f6da32bf90db55f (patch)
treef4a7d92201d294287c2452ccdb1d13f0fb6c1ff5
parent781228183a0e009b8c6c68aafb51681768744d9e (diff)
downloadorg-mode-cddea8c5422d7679db7ab2ef7f6da32bf90db55f.tar.gz
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.
-rw-r--r--lisp/org-docbook.el20
-rw-r--r--lisp/org-html.el20
-rw-r--r--lisp/org-list.el27
3 files changed, 36 insertions, 31 deletions
diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el
index 8190fff..f2518cd 100644
--- a/lisp/org-docbook.el
+++ b/lisp/org-docbook.el
@@ -1337,14 +1337,14 @@ modifications to buffer. STRUCT is the list structure. PREVS is
the alist of previous items."
(let* ((get-type
(function
- ;; Return type of list containing element POS, among
- ;; "ordered", "variable" or "itemized".
- (lambda (pos)
- (cond
- ((string-match "[[:alnum:]]" (org-list-get-bullet pos struct))
- "ordered")
- ((org-list-get-tag pos struct) "variable")
- (t "itemized")))))
+ ;; Translate type of list containing POS to "ordered",
+ ;; "variable" or "itemized".
+ (lambda (pos struct prevs)
+ (let ((type (org-list-get-list-type pos struct prevs)))
+ (cond
+ ((eq 'ordered type) "ordered")
+ ((eq 'descriptive type) "variable")
+ (t "itemized"))))))
(get-closings
(function
;; Return list of all items and sublists ending at POS, in
@@ -1364,7 +1364,7 @@ the alist of previous items."
(mapc (lambda (e)
(let* ((lastp (= (org-list-get-last-item e struct prevs) e))
(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
(org-export-docbook-close-para-maybe)
(insert (if (equal type "variable")
@@ -1389,7 +1389,7 @@ the alist of previous items."
(firstp (= list-beg pos))
;; Always refer to first item to determine list type, in
;; case list is ill-formed.
- (type (funcall get-type list-beg))
+ (type (funcall get-type list-beg struct prevs))
;; Special variables for ordered lists.
(order-type (let ((bullet (org-list-get-bullet list-beg struct)))
(cond
diff --git a/lisp/org-html.el b/lisp/org-html.el
index 5889270..7411ea8 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -2395,14 +2395,14 @@ modifications to buffer. STRUCT is the list structure. PREVS is
the alist of previous items."
(let* ((get-type
(function
- ;; Return type of list containing element POS, among "d",
- ;; "o" or "u".
- (lambda (pos)
- (cond
- ((string-match "[[:alnum:]]" (org-list-get-bullet pos struct))
- "o")
- ((org-list-get-tag pos struct) "d")
- (t "u")))))
+ ;; Translate type of list containing POS to "d", "o" or
+ ;; "u".
+ (lambda (pos struct prevs)
+ (let ((type (org-list-get-list-type pos struct prevs)))
+ (cond
+ ((eq 'ordered type) "o")
+ ((eq 'descriptive type) "d")
+ (t "u"))))))
(get-closings
(function
;; Return list of all items and sublists ending at POS, in
@@ -2422,7 +2422,7 @@ the alist of previous items."
(mapc (lambda (e)
(let* ((lastp (= (org-list-get-last-item e struct prevs) e))
(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)
;; Ending for every item
(org-close-li type)
@@ -2445,7 +2445,7 @@ the alist of previous items."
(firstp (= list-beg pos))
;; Always refer to first item to determine list type, in
;; case list is ill-formed.
- (type (funcall get-type list-beg))
+ (type (funcall get-type list-beg struct prevs))
;; Special variables for ordered lists.
(order-type (let ((bullet (org-list-get-bullet list-beg struct)))
(cond
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 29750f4..bfd22dc 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -1389,6 +1389,21 @@ STRUCT is the structure of the list. PREVS is the alist of
previous items. See `org-list-struct-prev-alist'."
(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)
"Return the Nth value of KEY in STRUCT."
(nth n (assq key struct)))
@@ -2501,22 +2516,12 @@ Point is left at list end."
(top (org-list-get-top-point struct))
(bottom (org-list-get-bottom-point struct))
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
(function
;; return a list whose car is list type and cdr a list of
;; items' body.
(lambda (e)
- (cons (funcall get-list-type (car e) struct)
+ (cons (org-list-get-list-type (car e) struct prevs)
(mapcar parse-item e)))))
(parse-item
(function