summaryrefslogtreecommitdiff
path: root/lisp/org/org-list.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/org/org-list.el')
-rw-r--r--lisp/org/org-list.el110
1 files changed, 74 insertions, 36 deletions
diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el
index 0cefa5cf89f..41d2e26fd7e 100644
--- a/lisp/org/org-list.el
+++ b/lisp/org/org-list.el
@@ -6,7 +6,7 @@
;; Bastien Guerry <bzg AT altern DOT org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.16
+;; Version: 6.19a
;;
;; This file is part of GNU Emacs.
;;
@@ -46,6 +46,7 @@
(declare-function org-trim "org" (s))
(declare-function org-get-indentation "org" (&optional line))
(declare-function org-timer-item "org-timer" (&optional arg))
+(declare-function org-combine-plists "org" (&rest plists))
(defgroup org-plain-lists nil
"Options concerning plain lists in Org-mode."
@@ -188,13 +189,20 @@ Return t when things worked, nil when we are not in an item."
(save-match-data
(and (looking-at "[ \t]*\\(.*?\\) ::")
(match-string 1)))))
+ (empty-line-p (save-excursion
+ (goto-char (match-beginning 0))
+ (and (not (bobp))
+ (or (beginning-of-line 0) t)
+ (save-match-data
+ (looking-at "[ \t]*$")))))
(timerp (and descp
(save-match-data
(string-match "^[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+$"
descp))))
(eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
(match-end 0)))
- (blank (cdr (assq 'plain-list-item org-blank-before-new-entry)))
+ (blank-a (cdr (assq 'plain-list-item org-blank-before-new-entry)))
+ (blank (if (eq blank-a 'auto) empty-line-p blank-a))
pos)
(if descp (setq checkbox nil))
(if timerp
@@ -894,9 +902,12 @@ sublevels as a list of strings."
(goto-char end))))
(nextindent (match-string 1))
(item (org-trim item))
- (item (if (string-match "^\\[.+\\]" item)
- (replace-match "\\\\texttt{\\&}"
- t nil item) item)))
+ (item (if (string-match "^\\[\\([xX ]\\)\\]" item)
+ (replace-match (if (equal (match-string 1 item) " ")
+ "[CBOFF]"
+ "[CBON]")
+ t nil item)
+ item)))
(push item output)
(when (> (length nextindent)
(length indent1))
@@ -1010,7 +1021,10 @@ Valid parameters PARAMS are
:istart String to start a list item
:iend String to end a list item
:isep String to separate items
-:lsep String to separate sublists"
+:lsep String to separate sublists
+
+:cboff String to insert for an unchecked checkbox
+:cbon String to insert for a checked checkbox"
(interactive)
(let* ((p params) sublist
(splicep (plist-get p :splice))
@@ -1027,7 +1041,9 @@ Valid parameters PARAMS are
(istart (plist-get p :istart))
(iend (plist-get p :iend))
(isep (plist-get p :isep))
- (lsep (plist-get p :lsep)))
+ (lsep (plist-get p :lsep))
+ (cbon (plist-get p :cbon))
+ (cboff (plist-get p :cboff)))
(let ((wrapper
(cond ((eq (car list) 'ordered)
(concat ostart "\n%s" oend "\n"))
@@ -1043,6 +1059,10 @@ Valid parameters PARAMS are
(setq term (org-trim (format (concat dtstart "%s" dtend)
(match-string 1 sublist))))
(setq sublist (substring sublist (1+ (length term)))))
+ (if (string-match "\\[CBON\\]" sublist)
+ (setq sublist (replace-match cbon t t sublist)))
+ (if (string-match "\\[CBOFF\\]" sublist)
+ (setq sublist (replace-match cboff t t sublist)))
(setq rtn (concat rtn istart term ddstart
sublist ddend iend isep)))
(t (setq rtn (concat rtn ;; previous list
@@ -1052,38 +1072,56 @@ Valid parameters PARAMS are
)))))
(format wrapper rtn))))
-(defun org-list-to-latex (list)
- "Convert LIST into a LaTeX list."
+(defun org-list-to-latex (list &optional params)
+ "Convert LIST into a LaTeX list.
+LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
+with overruling parameters for `org-list-to-generic'."
(org-list-to-generic
- list '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
- :ustart "\\begin{itemize}" :uend "\\end{itemize}"
- :dstart "\\begin{description}" :dend "\\end{description}"
- :dtstart "[" :dtend "]"
- :ddstart "" :ddend ""
- :istart "\\item " :iend ""
- :isep "\n" :lsep "\n")))
-
-(defun org-list-to-html (list)
- "Convert LIST into a HTML list."
+ list
+ (org-combine-plists
+ '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
+ :ustart "\\begin{itemize}" :uend "\\end{itemize}"
+ :dstart "\\begin{description}" :dend "\\end{description}"
+ :dtstart "[" :dtend "]"
+ :ddstart "" :ddend ""
+ :istart "\\item " :iend ""
+ :isep "\n" :lsep "\n"
+ :cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}")
+ params)))
+
+(defun org-list-to-html (list &optional params)
+ "Convert LIST into a HTML list.
+LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
+with overruling parameters for `org-list-to-generic'."
(org-list-to-generic
- list '(:splicep nil :ostart "<ol>" :oend "</ol>"
- :ustart "<ul>" :uend "</ul>"
- :dstart "<dl>" :dend "</dl>"
- :dtstart "<dt>" :dtend "</dt>"
- :ddstart "<dd>" :ddend "</dd>"
- :istart "<li>" :iend "</li>"
- :isep "\n" :lsep "\n")))
-
-(defun org-list-to-texinfo (list)
- "Convert LIST into a Texinfo list."
+ list
+ (org-combine-plists
+ '(:splicep nil :ostart "<ol>" :oend "</ol>"
+ :ustart "<ul>" :uend "</ul>"
+ :dstart "<dl>" :dend "</dl>"
+ :dtstart "<dt>" :dtend "</dt>"
+ :ddstart "<dd>" :ddend "</dd>"
+ :istart "<li>" :iend "</li>"
+ :isep "\n" :lsep "\n"
+ :cbon "<code>[X]</code>" :cboff "<code>[ ]</code>")
+ params)))
+
+(defun org-list-to-texinfo (list &optional params)
+ "Convert LIST into a Texinfo list.
+LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
+with overruling parameters for `org-list-to-generic'."
(org-list-to-generic
- list '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
- :ustart "@enumerate" :uend "@end enumerate"
- :dstart "@table" :dend "@end table"
- :dtstart "@item " :dtend "\n"
- :ddstart "" :ddend ""
- :istart "@item\n" :iend ""
- :isep "\n" :lsep "\n")))
+ list
+ (org-combine-plists
+ '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
+ :ustart "@enumerate" :uend "@end enumerate"
+ :dstart "@table" :dend "@end table"
+ :dtstart "@item " :dtend "\n"
+ :ddstart "" :ddend ""
+ :istart "@item\n" :iend ""
+ :isep "\n" :lsep "\n"
+ :cbon "@code{[X]}" :cboff "@code{[ ]}")
+ params)))
(provide 'org-list)