org-list.el 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  1. ;;; org-list.el --- Plain lists for Org-mode
  2. ;;
  3. ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
  4. ;; Free Software Foundation, Inc.
  5. ;;
  6. ;; Author: Carsten Dominik <carsten at orgmode dot org>
  7. ;; Bastien Guerry <bzg AT altern DOT org>
  8. ;; Keywords: outlines, hypermedia, calendar, wp
  9. ;; Homepage: http://orgmode.org
  10. ;; Version: 6.22trans
  11. ;;
  12. ;; This file is part of GNU Emacs.
  13. ;;
  14. ;; GNU Emacs is free software: you can redistribute it and/or modify
  15. ;; it under the terms of the GNU General Public License as published by
  16. ;; the Free Software Foundation, either version 3 of the License, or
  17. ;; (at your option) any later version.
  18. ;; GNU Emacs is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;; You should have received a copy of the GNU General Public License
  23. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  25. ;;
  26. ;;; Commentary:
  27. ;; This file contains the code dealing with plain lists in Org-mode.
  28. ;;; Code:
  29. (require 'org-macs)
  30. (require 'org-compat)
  31. (defvar org-blank-before-new-entry)
  32. (defvar org-M-RET-may-split-line)
  33. (declare-function org-invisible-p "org" ())
  34. (declare-function org-on-heading-p "org" (&optional invisible-ok))
  35. (declare-function outline-next-heading "outline" ())
  36. (declare-function outline-back-to-heading "outline" (&optional invisible-ok))
  37. (declare-function org-back-to-heading "org" (&optional invisible-ok))
  38. (declare-function org-back-over-empty-lines "org" ())
  39. (declare-function org-skip-whitespace "org" ())
  40. (declare-function org-trim "org" (s))
  41. (declare-function org-get-indentation "org" (&optional line))
  42. (declare-function org-timer-item "org-timer" (&optional arg))
  43. (declare-function org-combine-plists "org" (&rest plists))
  44. (defgroup org-plain-lists nil
  45. "Options concerning plain lists in Org-mode."
  46. :tag "Org Plain lists"
  47. :group 'org-structure)
  48. (defcustom org-cycle-include-plain-lists nil
  49. "Non-nil means, include plain lists into visibility cycling.
  50. This means that during cycling, plain list items will *temporarily* be
  51. interpreted as outline headlines with a level given by 1000+i where i is the
  52. indentation of the bullet. In all other operations, plain list items are
  53. not seen as headlines. For example, you cannot assign a TODO keyword to
  54. such an item."
  55. :group 'org-plain-lists
  56. :type 'boolean)
  57. (defcustom org-plain-list-ordered-item-terminator t
  58. "The character that makes a line with leading number an ordered list item.
  59. Valid values are ?. and ?\). To get both terminators, use t. While
  60. ?. may look nicer, it creates the danger that a line with leading
  61. number may be incorrectly interpreted as an item. ?\) therefore is
  62. the safe choice."
  63. :group 'org-plain-lists
  64. :type '(choice (const :tag "dot like in \"2.\"" ?.)
  65. (const :tag "paren like in \"2)\"" ?\))
  66. (const :tab "both" t)))
  67. (defcustom org-list-two-spaces-after-bullet-regexp nil
  68. "A regular expression matching bullets that should have 2 spaces after them.
  69. When nil, no bullet will have two spaces after them.
  70. When a string, it will be used as a regular expression. When the bullet
  71. type of a list is changed, the new bullet type will be matched against this
  72. regexp. If it matches, there will be two spaces instead of one after
  73. the bullet in each item of he list."
  74. :group 'org-plain-list
  75. :type '(choice
  76. (const :tag "never" nil)
  77. (regexp)))
  78. (defcustom org-empty-line-terminates-plain-lists nil
  79. "Non-nil means, an empty line ends all plain list levels.
  80. When nil, empty lines are part of the preceding item."
  81. :group 'org-plain-lists
  82. :type 'boolean)
  83. (defcustom org-auto-renumber-ordered-lists t
  84. "Non-nil means, automatically renumber ordered plain lists.
  85. Renumbering happens when the sequence have been changed with
  86. \\[org-shiftmetaup] or \\[org-shiftmetadown]. After other editing commands,
  87. use \\[org-ctrl-c-ctrl-c] to trigger renumbering."
  88. :group 'org-plain-lists
  89. :type 'boolean)
  90. (defcustom org-provide-checkbox-statistics t
  91. "Non-nil means, update checkbox statistics after insert and toggle.
  92. When this is set, checkbox statistics is updated each time you either insert
  93. a new checkbox with \\[org-insert-todo-heading] or toggle a checkbox
  94. with \\[org-ctrl-c-ctrl-c\\]."
  95. :group 'org-plain-lists
  96. :type 'boolean)
  97. (defcustom org-description-max-indent 20
  98. "Maximum indentation for the second line of a description list.
  99. When the indentation would be larger than this, it will become
  100. 5 characters instead."
  101. :group 'org-plain-lists
  102. :type 'integer)
  103. (defvar org-list-beginning-re
  104. "^\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) +\\(.*\\)$")
  105. (defcustom org-list-radio-list-templates
  106. '((latex-mode "% BEGIN RECEIVE ORGLST %n
  107. % END RECEIVE ORGLST %n
  108. \\begin{comment}
  109. #+ORGLST: SEND %n org-list-to-latex
  110. | | |
  111. \\end{comment}\n")
  112. (texinfo-mode "@c BEGIN RECEIVE ORGLST %n
  113. @c END RECEIVE ORGLST %n
  114. @ignore
  115. #+ORGLST: SEND %n org-list-to-texinfo
  116. | | |
  117. @end ignore\n")
  118. (html-mode "<!-- BEGIN RECEIVE ORGLST %n -->
  119. <!-- END RECEIVE ORGLST %n -->
  120. <!--
  121. #+ORGLST: SEND %n org-list-to-html
  122. | | |
  123. -->\n"))
  124. "Templates for radio lists in different major modes.
  125. All occurrences of %n in a template will be replaced with the name of the
  126. list, obtained by prompting the user."
  127. :group 'org-plain-lists
  128. :type '(repeat
  129. (list (symbol :tag "Major mode")
  130. (string :tag "Format"))))
  131. ;;;; Plain list items, including checkboxes
  132. ;;; Plain list items
  133. (defun org-at-item-p ()
  134. "Is point in a line starting a hand-formatted item?"
  135. (let ((llt org-plain-list-ordered-item-terminator))
  136. (save-excursion
  137. (goto-char (point-at-bol))
  138. (looking-at
  139. (cond
  140. ((eq llt t) "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
  141. ((= llt ?.) "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
  142. ((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+))\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
  143. (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))))))
  144. (defun org-at-item-bullet-p ()
  145. "Is point at the bullet of a plain list item?"
  146. (and (org-at-item-p)
  147. (not (member (char-after) '(?\ ?\t)))
  148. (< (point) (match-end 0))))
  149. (defun org-in-item-p ()
  150. "It the cursor inside a plain list item.
  151. Does not have to be the first line."
  152. (save-excursion
  153. (condition-case nil
  154. (progn
  155. (org-beginning-of-item)
  156. (org-at-item-p)
  157. t)
  158. (error nil))))
  159. (defun org-insert-item (&optional checkbox)
  160. "Insert a new item at the current level.
  161. Return t when things worked, nil when we are not in an item."
  162. (when (save-excursion
  163. (condition-case nil
  164. (progn
  165. (org-beginning-of-item)
  166. (org-at-item-p)
  167. (if (org-invisible-p) (error "Invisible item"))
  168. t)
  169. (error nil)))
  170. (let* ((bul (match-string 0))
  171. (descp (save-excursion (goto-char (match-beginning 0))
  172. (beginning-of-line 1)
  173. (save-match-data
  174. (and (looking-at "[ \t]*\\(.*?\\) ::")
  175. (match-string 1)))))
  176. (empty-line-p (save-excursion
  177. (goto-char (match-beginning 0))
  178. (and (not (bobp))
  179. (or (beginning-of-line 0) t)
  180. (save-match-data
  181. (looking-at "[ \t]*$")))))
  182. (timerp (and descp
  183. (save-match-data
  184. (string-match "^[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+$"
  185. descp))))
  186. (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
  187. (match-end 0)))
  188. (blank-a (cdr (assq 'plain-list-item org-blank-before-new-entry)))
  189. (blank (if (eq blank-a 'auto) empty-line-p blank-a))
  190. pos)
  191. (if descp (setq checkbox nil))
  192. (if timerp
  193. (progn (org-timer-item) t)
  194. (cond
  195. ((and (org-at-item-p) (<= (point) eow))
  196. ;; before the bullet
  197. (beginning-of-line 1)
  198. (open-line (if blank 2 1)))
  199. ((<= (point) eow)
  200. (beginning-of-line 1))
  201. (t
  202. (unless (org-get-alist-option org-M-RET-may-split-line 'item)
  203. (end-of-line 1)
  204. (delete-horizontal-space))
  205. (newline (if blank 2 1))))
  206. (insert bul
  207. (if checkbox "[ ]" "")
  208. (if descp (concat (if checkbox " " "")
  209. (read-string "Term: ") " :: ") ""))
  210. (just-one-space)
  211. (setq pos (point))
  212. (end-of-line 1)
  213. (unless (= (point) pos) (just-one-space) (backward-delete-char 1)))
  214. (org-maybe-renumber-ordered-list)
  215. (and checkbox (org-update-checkbox-count-maybe))
  216. t)))
  217. ;;; Checkboxes
  218. (defun org-at-item-checkbox-p ()
  219. "Is point at a line starting a plain-list item with a checklet?"
  220. (and (org-at-item-p)
  221. (save-excursion
  222. (goto-char (match-end 0))
  223. (skip-chars-forward " \t")
  224. (looking-at "\\[[- X]\\]"))))
  225. (defun org-toggle-checkbox (&optional toggle-presence)
  226. "Toggle the checkbox in the current line.
  227. With prefix arg TOGGLE-PRESENCE, add or remove checkboxes.
  228. With double prefix, set checkbox to [-].
  229. When there is an active region, toggle status or presence of the checkbox
  230. in the first line, and make every item in the region have the same
  231. status or presence, respectively.
  232. If the cursor is in a headline, apply this to all checkbox items in the
  233. text below the heading."
  234. (interactive "P")
  235. (catch 'exit
  236. (let (beg end status first-present first-status)
  237. (cond
  238. ((org-region-active-p)
  239. (setq beg (region-beginning) end (region-end)))
  240. ((org-on-heading-p)
  241. (setq beg (point) end (save-excursion (outline-next-heading) (point))))
  242. ((org-at-item-checkbox-p)
  243. (let ((pos (point)))
  244. (if (equal toggle-presence '(4))
  245. (progn
  246. (replace-match "")
  247. (goto-char (match-beginning 0))
  248. (just-one-space))
  249. (replace-match
  250. (cond ((equal toggle-presence '(16)) "[-]")
  251. ((member (match-string 0) '("[ ]" "[-]")) "[X]")
  252. (t "[ ]"))
  253. t t))
  254. (goto-char pos))
  255. (throw 'exit t))
  256. ((org-at-item-p)
  257. ;; add a checkbox
  258. (save-excursion
  259. (goto-char (match-end 0))
  260. (insert "[ ] "))
  261. (throw 'exit t))
  262. (t (error "Not at a checkbox or heading, and no active region")))
  263. (setq end (move-marker (make-marker) end))
  264. (save-excursion
  265. (goto-char beg)
  266. (setq first-present (org-at-item-checkbox-p)
  267. first-status
  268. (save-excursion
  269. (and (re-search-forward "[ \t]\\(\\[[ X]\\]\\)" end t)
  270. (equal (match-string 1) "[X]"))))
  271. (while (< (point) end)
  272. (if toggle-presence
  273. (cond
  274. ((and first-present (org-at-item-checkbox-p))
  275. (save-excursion
  276. (replace-match "")
  277. (goto-char (match-beginning 0))
  278. (just-one-space)))
  279. ((and (not first-present) (not (org-at-item-checkbox-p))
  280. (org-at-item-p))
  281. (save-excursion
  282. (goto-char (match-end 0))
  283. (insert "[ ] "))))
  284. (when (org-at-item-checkbox-p)
  285. (setq status (equal (match-string 0) "[X]"))
  286. (replace-match
  287. (if first-status "[ ]" "[X]") t t)))
  288. (beginning-of-line 2)))))
  289. (org-update-checkbox-count-maybe))
  290. (defun org-update-checkbox-count-maybe ()
  291. "Update checkbox statistics unless turned off by user."
  292. (when org-provide-checkbox-statistics
  293. (org-update-checkbox-count)))
  294. (defun org-update-checkbox-count (&optional all)
  295. "Update the checkbox statistics in the current section.
  296. This will find all statistic cookies like [57%] and [6/12] and update them
  297. with the current numbers. With optional prefix argument ALL, do this for
  298. the whole buffer."
  299. (interactive "P")
  300. (save-excursion
  301. (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
  302. (beg (condition-case nil
  303. (progn (org-back-to-heading) (point))
  304. (error (point-min))))
  305. (end (move-marker (make-marker)
  306. (progn (outline-next-heading) (point))))
  307. (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
  308. (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
  309. (re-find (concat re "\\|" re-box))
  310. beg-cookie end-cookie is-percent c-on c-off lim
  311. eline curr-ind next-ind continue-from startsearch
  312. (cstat 0)
  313. )
  314. (when all
  315. (goto-char (point-min))
  316. (outline-next-heading)
  317. (setq beg (point) end (point-max)))
  318. (goto-char end)
  319. ;; find each statistic cookie
  320. (while (re-search-backward re-find beg t)
  321. (setq beg-cookie (match-beginning 1)
  322. end-cookie (match-end 1)
  323. cstat (+ cstat (if end-cookie 1 0))
  324. startsearch (point-at-eol)
  325. continue-from (match-beginning 0)
  326. is-percent (match-beginning 2)
  327. lim (cond
  328. ((org-on-heading-p) (outline-next-heading) (point))
  329. ((org-at-item-p) (org-end-of-item) (point))
  330. (t nil))
  331. c-on 0
  332. c-off 0)
  333. (when lim
  334. ;; find first checkbox for this cookie and gather
  335. ;; statistics from all that are at this indentation level
  336. (goto-char startsearch)
  337. (if (re-search-forward re-box lim t)
  338. (progn
  339. (org-beginning-of-item)
  340. (setq curr-ind (org-get-indentation))
  341. (setq next-ind curr-ind)
  342. (while (and (bolp) (org-at-item-p) (= curr-ind next-ind))
  343. (save-excursion (end-of-line) (setq eline (point)))
  344. (if (re-search-forward re-box eline t)
  345. (if (member (match-string 2) '("[ ]" "[-]"))
  346. (setq c-off (1+ c-off))
  347. (setq c-on (1+ c-on))
  348. )
  349. )
  350. (org-end-of-item)
  351. (setq next-ind (org-get-indentation))
  352. )))
  353. (goto-char continue-from)
  354. ;; update cookie
  355. (when end-cookie
  356. (delete-region beg-cookie end-cookie)
  357. (goto-char beg-cookie)
  358. (insert
  359. (if is-percent
  360. (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
  361. (format "[%d/%d]" c-on (+ c-on c-off)))))
  362. ;; update items checkbox if it has one
  363. (when (org-at-item-p)
  364. (org-beginning-of-item)
  365. (when (and (> (+ c-on c-off) 0)
  366. (re-search-forward re-box (point-at-eol) t))
  367. (setq beg-cookie (match-beginning 2)
  368. end-cookie (match-end 2))
  369. (delete-region beg-cookie end-cookie)
  370. (goto-char beg-cookie)
  371. (cond ((= c-off 0) (insert "[X]"))
  372. ((= c-on 0) (insert "[ ]"))
  373. (t (insert "[-]")))
  374. )))
  375. (goto-char continue-from))
  376. (when (interactive-p)
  377. (message "Checkbox statistics updated %s (%d places)"
  378. (if all "in entire file" "in current outline entry") cstat)))))
  379. (defun org-get-checkbox-statistics-face ()
  380. "Select the face for checkbox statistics.
  381. The face will be `org-done' when all relevant boxes are checked. Otherwise
  382. it will be `org-todo'."
  383. (if (match-end 1)
  384. (if (equal (match-string 1) "100%") 'org-done 'org-todo)
  385. (if (and (> (match-end 2) (match-beginning 2))
  386. (equal (match-string 2) (match-string 3)))
  387. 'org-done
  388. 'org-todo)))
  389. (defun org-beginning-of-item ()
  390. "Go to the beginning of the current hand-formatted item.
  391. If the cursor is not in an item, throw an error."
  392. (interactive)
  393. (let ((pos (point))
  394. (limit (save-excursion
  395. (condition-case nil
  396. (progn
  397. (org-back-to-heading)
  398. (beginning-of-line 2) (point))
  399. (error (point-min)))))
  400. (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
  401. ind ind1)
  402. (if (org-at-item-p)
  403. (beginning-of-line 1)
  404. (beginning-of-line 1)
  405. (skip-chars-forward " \t")
  406. (setq ind (current-column))
  407. (if (catch 'exit
  408. (while t
  409. (beginning-of-line 0)
  410. (if (or (bobp) (< (point) limit)) (throw 'exit nil))
  411. (if (looking-at "[ \t]*$")
  412. (setq ind1 ind-empty)
  413. (skip-chars-forward " \t")
  414. (setq ind1 (current-column)))
  415. (if (< ind1 ind)
  416. (progn (beginning-of-line 1) (throw 'exit (org-at-item-p))))))
  417. nil
  418. (goto-char pos)
  419. (error "Not in an item")))))
  420. (defun org-end-of-item ()
  421. "Go to the end of the current hand-formatted item.
  422. If the cursor is not in an item, throw an error."
  423. (interactive)
  424. (let* ((pos (point))
  425. ind1
  426. (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
  427. (limit (save-excursion (outline-next-heading) (point)))
  428. (ind (save-excursion
  429. (org-beginning-of-item)
  430. (skip-chars-forward " \t")
  431. (current-column)))
  432. (end (catch 'exit
  433. (while t
  434. (beginning-of-line 2)
  435. (if (eobp) (throw 'exit (point)))
  436. (if (>= (point) limit) (throw 'exit (point-at-bol)))
  437. (if (looking-at "[ \t]*$")
  438. (setq ind1 ind-empty)
  439. (skip-chars-forward " \t")
  440. (setq ind1 (current-column)))
  441. (if (<= ind1 ind)
  442. (throw 'exit (point-at-bol)))))))
  443. (if end
  444. (goto-char end)
  445. (goto-char pos)
  446. (error "Not in an item"))))
  447. (defun org-next-item ()
  448. "Move to the beginning of the next item in the current plain list.
  449. Error if not at a plain list, or if this is the last item in the list."
  450. (interactive)
  451. (let (ind ind1 (pos (point)))
  452. (org-beginning-of-item)
  453. (setq ind (org-get-indentation))
  454. (org-end-of-item)
  455. (setq ind1 (org-get-indentation))
  456. (unless (and (org-at-item-p) (= ind ind1))
  457. (goto-char pos)
  458. (error "On last item"))))
  459. (defun org-previous-item ()
  460. "Move to the beginning of the previous item in the current plain list.
  461. Error if not at a plain list, or if this is the first item in the list."
  462. (interactive)
  463. (let (beg ind ind1 (pos (point)))
  464. (org-beginning-of-item)
  465. (setq beg (point))
  466. (setq ind (org-get-indentation))
  467. (goto-char beg)
  468. (catch 'exit
  469. (while t
  470. (beginning-of-line 0)
  471. (if (looking-at "[ \t]*$")
  472. nil
  473. (if (<= (setq ind1 (org-get-indentation)) ind)
  474. (throw 'exit t)))))
  475. (condition-case nil
  476. (if (or (not (org-at-item-p))
  477. (< ind1 (1- ind)))
  478. (error "")
  479. (org-beginning-of-item))
  480. (error (goto-char pos)
  481. (error "On first item")))))
  482. (defun org-first-list-item-p ()
  483. "Is this heading the item in a plain list?"
  484. (unless (org-at-item-p)
  485. (error "Not at a plain list item"))
  486. (org-beginning-of-item)
  487. (= (point) (save-excursion (org-beginning-of-item-list))))
  488. (defun org-move-item-down ()
  489. "Move the plain list item at point down, i.e. swap with following item.
  490. Subitems (items with larger indentation) are considered part of the item,
  491. so this really moves item trees."
  492. (interactive)
  493. (let ((col (current-column))
  494. (pos (point))
  495. beg beg0 end end0 ind ind1 txt ne-end ne-beg)
  496. (org-beginning-of-item)
  497. (setq beg0 (point))
  498. (save-excursion
  499. (setq ne-beg (org-back-over-empty-lines))
  500. (setq beg (point)))
  501. (goto-char beg0)
  502. (setq ind (org-get-indentation))
  503. (org-end-of-item)
  504. (setq end0 (point))
  505. (setq ind1 (org-get-indentation))
  506. (setq ne-end (org-back-over-empty-lines))
  507. (setq end (point))
  508. (goto-char beg0)
  509. (when (and (org-first-list-item-p) (< ne-end ne-beg))
  510. ;; include less whitespace
  511. (save-excursion
  512. (goto-char beg)
  513. (forward-line (- ne-beg ne-end))
  514. (setq beg (point))))
  515. (goto-char end0)
  516. (if (and (org-at-item-p) (= ind ind1))
  517. (progn
  518. (org-end-of-item)
  519. (org-back-over-empty-lines)
  520. (setq txt (buffer-substring beg end))
  521. (save-excursion
  522. (delete-region beg end))
  523. (setq pos (point))
  524. (insert txt)
  525. (goto-char pos) (org-skip-whitespace)
  526. (org-maybe-renumber-ordered-list)
  527. (move-to-column col))
  528. (goto-char pos)
  529. (move-to-column col)
  530. (error "Cannot move this item further down"))))
  531. (defun org-move-item-up (arg)
  532. "Move the plain list item at point up, i.e. swap with previous item.
  533. Subitems (items with larger indentation) are considered part of the item,
  534. so this really moves item trees."
  535. (interactive "p")
  536. (let ((col (current-column)) (pos (point))
  537. beg beg0 end ind ind1 txt
  538. ne-beg ne-ins ins-end)
  539. (org-beginning-of-item)
  540. (setq beg0 (point))
  541. (setq ind (org-get-indentation))
  542. (save-excursion
  543. (setq ne-beg (org-back-over-empty-lines))
  544. (setq beg (point)))
  545. (goto-char beg0)
  546. (org-end-of-item)
  547. (org-back-over-empty-lines)
  548. (setq end (point))
  549. (goto-char beg0)
  550. (catch 'exit
  551. (while t
  552. (beginning-of-line 0)
  553. (if (looking-at "[ \t]*$")
  554. (if org-empty-line-terminates-plain-lists
  555. (progn
  556. (goto-char pos)
  557. (error "Cannot move this item further up"))
  558. nil)
  559. (if (<= (setq ind1 (org-get-indentation)) ind)
  560. (throw 'exit t)))))
  561. (condition-case nil
  562. (org-beginning-of-item)
  563. (error (goto-char beg0)
  564. (move-to-column col)
  565. (error "Cannot move this item further up")))
  566. (setq ind1 (org-get-indentation))
  567. (if (and (org-at-item-p) (= ind ind1))
  568. (progn
  569. (setq ne-ins (org-back-over-empty-lines))
  570. (setq txt (buffer-substring beg end))
  571. (save-excursion
  572. (delete-region beg end))
  573. (setq pos (point))
  574. (insert txt)
  575. (setq ins-end (point))
  576. (goto-char pos) (org-skip-whitespace)
  577. (when (and (org-first-list-item-p) (> ne-ins ne-beg))
  578. ;; Move whitespace back to beginning
  579. (save-excursion
  580. (goto-char ins-end)
  581. (let ((kill-whole-line t))
  582. (kill-line (- ne-ins ne-beg)) (point)))
  583. (insert (make-string (- ne-ins ne-beg) ?\n)))
  584. (org-maybe-renumber-ordered-list)
  585. (move-to-column col))
  586. (goto-char pos)
  587. (move-to-column col)
  588. (error "Cannot move this item further up"))))
  589. (defun org-maybe-renumber-ordered-list ()
  590. "Renumber the ordered list at point if setup allows it.
  591. This tests the user option `org-auto-renumber-ordered-lists' before
  592. doing the renumbering."
  593. (interactive)
  594. (when (and org-auto-renumber-ordered-lists
  595. (org-at-item-p))
  596. (if (match-beginning 3)
  597. (org-renumber-ordered-list 1)
  598. (org-fix-bullet-type))))
  599. (defun org-maybe-renumber-ordered-list-safe ()
  600. (condition-case nil
  601. (save-excursion
  602. (org-maybe-renumber-ordered-list))
  603. (error nil)))
  604. (defun org-cycle-list-bullet (&optional which)
  605. "Cycle through the different itemize/enumerate bullets.
  606. This cycle the entire list level through the sequence:
  607. `-' -> `+' -> `*' -> `1.' -> `1)'
  608. If WHICH is a string, use that as the new bullet. If WHICH is an integer,
  609. 0 means `-', 1 means `+' etc."
  610. (interactive "P")
  611. (org-preserve-lc
  612. (org-beginning-of-item-list)
  613. (org-at-item-p)
  614. (beginning-of-line 1)
  615. (let ((current (match-string 0))
  616. (prevp (eq which 'previous))
  617. new old)
  618. (setq new (cond
  619. ((and (numberp which)
  620. (nth (1- which) '("-" "+" "*" "1." "1)"))))
  621. ((string-match "-" current) (if prevp "1)" "+"))
  622. ((string-match "\\+" current)
  623. (if prevp "-" (if (looking-at "\\S-") "1." "*")))
  624. ((string-match "\\*" current) (if prevp "+" "1."))
  625. ((string-match "\\." current)
  626. (if prevp (if (looking-at "\\S-") "+" "*") "1)"))
  627. ((string-match ")" current) (if prevp "1." "-"))
  628. (t (error "This should not happen"))))
  629. (and (looking-at "\\([ \t]*\\)\\(\\S-+\\)")
  630. (setq old (match-string 2))
  631. (replace-match (concat "\\1" new)))
  632. (org-shift-item-indentation (- (length new) (length old)))
  633. (org-fix-bullet-type)
  634. (org-maybe-renumber-ordered-list))))
  635. (defun org-get-string-indentation (s)
  636. "What indentation has S due to SPACE and TAB at the beginning of the string?"
  637. (let ((n -1) (i 0) (w tab-width) c)
  638. (catch 'exit
  639. (while (< (setq n (1+ n)) (length s))
  640. (setq c (aref s n))
  641. (cond ((= c ?\ ) (setq i (1+ i)))
  642. ((= c ?\t) (setq i (* (/ (+ w i) w) w)))
  643. (t (throw 'exit t)))))
  644. i))
  645. (defun org-renumber-ordered-list (arg)
  646. "Renumber an ordered plain list.
  647. Cursor needs to be in the first line of an item, the line that starts
  648. with something like \"1.\" or \"2)\"."
  649. (interactive "p")
  650. (unless (and (org-at-item-p)
  651. (match-beginning 3))
  652. (error "This is not an ordered list"))
  653. (let ((line (org-current-line))
  654. (col (current-column))
  655. (ind (org-get-string-indentation
  656. (buffer-substring (point-at-bol) (match-beginning 3))))
  657. ;; (term (substring (match-string 3) -1))
  658. ind1 (n (1- arg))
  659. fmt bobp old new)
  660. ;; find where this list begins
  661. (org-beginning-of-item-list)
  662. (setq bobp (bobp))
  663. (looking-at "[ \t]*[0-9]+\\([.)]\\)")
  664. (setq fmt (concat "%d" (match-string 1)))
  665. (beginning-of-line 0)
  666. ;; walk forward and replace these numbers
  667. (catch 'exit
  668. (while t
  669. (catch 'next
  670. (if bobp (setq bobp nil) (beginning-of-line 2))
  671. (if (eobp) (throw 'exit nil))
  672. (if (looking-at "[ \t]*$") (throw 'next nil))
  673. (skip-chars-forward " \t") (setq ind1 (current-column))
  674. (if (> ind1 ind) (throw 'next t))
  675. (if (< ind1 ind) (throw 'exit t))
  676. (if (not (org-at-item-p)) (throw 'exit nil))
  677. (setq old (match-string 2))
  678. (delete-region (match-beginning 2) (match-end 2))
  679. (goto-char (match-beginning 2))
  680. (insert (setq new (format fmt (setq n (1+ n)))))
  681. (org-shift-item-indentation (- (length new) (length old))))))
  682. (goto-line line)
  683. (org-move-to-column col)))
  684. (defun org-fix-bullet-type ()
  685. "Make sure all items in this list have the same bullet as the first item.
  686. Also, fix the indentation."
  687. (interactive)
  688. (unless (org-at-item-p) (error "This is not a list"))
  689. (let ((line (org-current-line))
  690. (col (current-column))
  691. (ind (current-indentation))
  692. ind1 bullet oldbullet)
  693. ;; find where this list begins
  694. (org-beginning-of-item-list)
  695. (beginning-of-line 1)
  696. ;; find out what the bullet type is
  697. (looking-at "[ \t]*\\(\\S-+\\)")
  698. (setq bullet (concat (match-string 1) " "))
  699. (if (and org-list-two-spaces-after-bullet-regexp
  700. (string-match org-list-two-spaces-after-bullet-regexp bullet))
  701. (setq bullet (concat bullet " ")))
  702. ;; walk forward and replace these numbers
  703. (beginning-of-line 0)
  704. (catch 'exit
  705. (while t
  706. (catch 'next
  707. (beginning-of-line 2)
  708. (if (eobp) (throw 'exit nil))
  709. (if (looking-at "[ \t]*$") (throw 'next nil))
  710. (skip-chars-forward " \t") (setq ind1 (current-column))
  711. (if (> ind1 ind) (throw 'next t))
  712. (if (< ind1 ind) (throw 'exit t))
  713. (if (not (org-at-item-p)) (throw 'exit nil))
  714. (skip-chars-forward " \t")
  715. (looking-at "\\S-+ *")
  716. (setq oldbullet (match-string 0))
  717. (replace-match bullet)
  718. (org-shift-item-indentation (- (length bullet) (length oldbullet))))))
  719. (goto-line line)
  720. (org-move-to-column col)
  721. (if (string-match "[0-9]" bullet)
  722. (org-renumber-ordered-list 1))))
  723. (defun org-shift-item-indentation (delta)
  724. "Shift the indentation in current item by DELTA."
  725. (save-excursion
  726. (let ((beg (point-at-bol))
  727. (end (progn (org-end-of-item) (point)))
  728. i)
  729. (goto-char end)
  730. (beginning-of-line 0)
  731. (while (> (point) beg)
  732. (when (looking-at "[ \t]*\\S-")
  733. ;; this is not an empty line
  734. (setq i (org-get-indentation))
  735. (if (and (> i 0) (> (setq i (+ i delta)) 0))
  736. (indent-line-to i)))
  737. (beginning-of-line 0)))))
  738. (defun org-beginning-of-item-list ()
  739. "Go to the beginning of the current item list.
  740. I.e. to the first item in this list."
  741. (interactive)
  742. (org-beginning-of-item)
  743. (let ((pos (point-at-bol))
  744. (ind (org-get-indentation))
  745. ind1)
  746. ;; find where this list begins
  747. (catch 'exit
  748. (while t
  749. (catch 'next
  750. (beginning-of-line 0)
  751. (if (looking-at "[ \t]*$")
  752. (throw (if (bobp) 'exit 'next) t))
  753. (skip-chars-forward " \t") (setq ind1 (current-column))
  754. (if (or (< ind1 ind)
  755. (and (= ind1 ind)
  756. (not (org-at-item-p)))
  757. (and (= (point-at-bol) (point-min))
  758. (setq pos (point-min))))
  759. (throw 'exit t)
  760. (when (org-at-item-p) (setq pos (point-at-bol)))))))
  761. (goto-char pos)))
  762. (defun org-end-of-item-list ()
  763. "Go to the end of the current item list.
  764. I.e. to the text after the last item."
  765. (interactive)
  766. (org-beginning-of-item)
  767. (let ((pos (point-at-bol))
  768. (ind (org-get-indentation))
  769. ind1)
  770. ;; find where this list begins
  771. (catch 'exit
  772. (while t
  773. (catch 'next
  774. (beginning-of-line 2)
  775. (if (looking-at "[ \t]*$")
  776. (throw (if (eobp) 'exit 'next) t))
  777. (skip-chars-forward " \t") (setq ind1 (current-column))
  778. (if (or (< ind1 ind)
  779. (and (= ind1 ind)
  780. (not (org-at-item-p)))
  781. (eobp))
  782. (progn
  783. (setq pos (point-at-bol))
  784. (throw 'exit t))))))
  785. (goto-char pos)))
  786. (defvar org-last-indent-begin-marker (make-marker))
  787. (defvar org-last-indent-end-marker (make-marker))
  788. (defun org-outdent-item (arg)
  789. "Outdent a local list item."
  790. (interactive "p")
  791. (org-indent-item (- arg)))
  792. (defun org-indent-item (arg)
  793. "Indent a local list item."
  794. (interactive "p")
  795. (unless (org-at-item-p)
  796. (error "Not on an item"))
  797. (save-excursion
  798. (let (beg end ind ind1 tmp delta ind-down ind-up)
  799. (if (memq last-command '(org-shiftmetaright org-shiftmetaleft))
  800. (setq beg org-last-indent-begin-marker
  801. end org-last-indent-end-marker)
  802. (org-beginning-of-item)
  803. (setq beg (move-marker org-last-indent-begin-marker (point)))
  804. (org-end-of-item)
  805. (setq end (move-marker org-last-indent-end-marker (point))))
  806. (goto-char beg)
  807. (setq tmp (org-item-indent-positions)
  808. ind (car tmp)
  809. ind-down (nth 2 tmp)
  810. ind-up (nth 1 tmp)
  811. delta (if (> arg 0)
  812. (if ind-down (- ind-down ind) 2)
  813. (if ind-up (- ind-up ind) -2)))
  814. (if (< (+ delta ind) 0) (error "Cannot outdent beyond margin"))
  815. (while (< (point) end)
  816. (beginning-of-line 1)
  817. (skip-chars-forward " \t") (setq ind1 (current-column))
  818. (delete-region (point-at-bol) (point))
  819. (or (eolp) (org-indent-to-column (+ ind1 delta)))
  820. (beginning-of-line 2))))
  821. (org-fix-bullet-type)
  822. (org-maybe-renumber-ordered-list-safe)
  823. (save-excursion
  824. (beginning-of-line 0)
  825. (condition-case nil (org-beginning-of-item) (error nil))
  826. (org-maybe-renumber-ordered-list-safe)))
  827. (defun org-item-indent-positions ()
  828. "Return indentation for plain list items.
  829. This returns a list with three values: The current indentation, the
  830. parent indentation and the indentation a child should have.
  831. Assumes cursor in item line."
  832. (let* ((bolpos (point-at-bol))
  833. (ind (org-get-indentation))
  834. ind-down ind-up pos)
  835. (save-excursion
  836. (org-beginning-of-item-list)
  837. (skip-chars-backward "\n\r \t")
  838. (when (org-in-item-p)
  839. (org-beginning-of-item)
  840. (setq ind-up (org-get-indentation))))
  841. (setq pos (point))
  842. (save-excursion
  843. (cond
  844. ((and (condition-case nil (progn (org-previous-item) t)
  845. (error nil))
  846. (or (forward-char 1) t)
  847. (re-search-forward "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)" bolpos t))
  848. (setq ind-down (org-get-indentation)))
  849. ((and (goto-char pos)
  850. (org-at-item-p))
  851. (goto-char (match-end 0))
  852. (skip-chars-forward " \t")
  853. (setq ind-down (current-column)))))
  854. (list ind ind-up ind-down)))
  855. ;;; Send and receive lists
  856. (defun org-list-parse-list (&optional delete)
  857. "Parse the list at point and maybe DELETE it.
  858. Return a list containing first level items as strings and
  859. sublevels as a list of strings."
  860. (let* ((item-beginning (org-list-item-beginning))
  861. (start (car item-beginning))
  862. (end (org-list-end (cdr item-beginning)))
  863. output itemsep ltype)
  864. (while (re-search-forward org-list-beginning-re end t)
  865. (goto-char (match-beginning 3))
  866. (save-match-data
  867. (cond ((string-match "[0-9]" (match-string 2))
  868. (setq itemsep "[0-9]+\\(?:\\.\\|)\\)"
  869. ltype 'ordered))
  870. ((string-match "^.*::" (match-string 0))
  871. (setq itemsep "[-+]" ltype 'descriptive))
  872. (t (setq itemsep "[-+]" ltype 'unordered))))
  873. (let* ((indent1 (match-string 1))
  874. (nextitem (save-excursion
  875. (save-match-data
  876. (or (and (re-search-forward
  877. (concat "^" indent1 itemsep " *?") end t)
  878. (match-beginning 0)) end))))
  879. (item (buffer-substring
  880. (point)
  881. (or (and (re-search-forward
  882. org-list-beginning-re end t)
  883. (goto-char (match-beginning 0)))
  884. (goto-char end))))
  885. (nextindent (match-string 1))
  886. (item (org-trim item))
  887. (item (if (string-match "^\\[\\([xX ]\\)\\]" item)
  888. (replace-match (if (equal (match-string 1 item) " ")
  889. "[CBOFF]"
  890. "[CBON]")
  891. t nil item)
  892. item)))
  893. (push item output)
  894. (when (> (length nextindent)
  895. (length indent1))
  896. (narrow-to-region (point) nextitem)
  897. (push (org-list-parse-list) output)
  898. (widen))))
  899. (when delete (delete-region start end))
  900. (setq output (nreverse output))
  901. (push ltype output)))
  902. (defun org-list-item-beginning ()
  903. "Find the beginning of the list item.
  904. Return a cons which car is the beginning position of the item and
  905. cdr is the indentation string."
  906. (save-excursion
  907. (if (not (or (looking-at org-list-beginning-re)
  908. (re-search-backward
  909. org-list-beginning-re nil t)))
  910. (progn (goto-char (point-min)) (point))
  911. (cons (match-beginning 0) (match-string 1)))))
  912. (defun org-list-end (indent)
  913. "Return the position of the end of the list.
  914. INDENT is the indentation of the list."
  915. (save-excursion
  916. (catch 'exit
  917. (while (or (looking-at org-list-beginning-re)
  918. (looking-at (concat "^" indent "[ \t]+\\|^$")))
  919. (if (eq (point) (point-max))
  920. (throw 'exit (point-max)))
  921. (forward-line 1))) (point)))
  922. (defun org-list-insert-radio-list ()
  923. "Insert a radio list template appropriate for this major mode."
  924. (interactive)
  925. (let* ((e (assq major-mode org-list-radio-list-templates))
  926. (txt (nth 1 e))
  927. name pos)
  928. (unless e (error "No radio list setup defined for %s" major-mode))
  929. (setq name (read-string "List name: "))
  930. (while (string-match "%n" txt)
  931. (setq txt (replace-match name t t txt)))
  932. (or (bolp) (insert "\n"))
  933. (setq pos (point))
  934. (insert txt)
  935. (goto-char pos)))
  936. (defun org-list-send-list (&optional maybe)
  937. "Send a tranformed version of this list to the receiver position.
  938. With argument MAYBE, fail quietly if no transformation is defined for
  939. this list."
  940. (interactive)
  941. (catch 'exit
  942. (unless (org-at-item-p) (error "Not at a list"))
  943. (save-excursion
  944. (goto-char (car (org-list-item-beginning)))
  945. (beginning-of-line 0)
  946. (unless (looking-at "#\\+ORGLST: *SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
  947. (if maybe
  948. (throw 'exit nil)
  949. (error "Don't know how to transform this list"))))
  950. (let* ((name (match-string 1))
  951. (item-beginning (org-list-item-beginning))
  952. (transform (intern (match-string 2)))
  953. (txt (buffer-substring-no-properties
  954. (car item-beginning)
  955. (org-list-end (cdr item-beginning))))
  956. (list (org-list-parse-list))
  957. beg)
  958. (unless (fboundp transform)
  959. (error "No such transformation function %s" transform))
  960. (setq txt (funcall transform list))
  961. ;; Find the insertion place
  962. (save-excursion
  963. (goto-char (point-min))
  964. (unless (re-search-forward
  965. (concat "BEGIN RECEIVE ORGLST +" name "\\([ \t]\\|$\\)") nil t)
  966. (error "Don't know where to insert translated list"))
  967. (goto-char (match-beginning 0))
  968. (beginning-of-line 2)
  969. (setq beg (point))
  970. (unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t)
  971. (error "Cannot find end of insertion region"))
  972. (beginning-of-line 1)
  973. (delete-region beg (point))
  974. (goto-char beg)
  975. (insert txt "\n"))
  976. (message "List converted and installed at receiver location"))))
  977. (defun org-list-to-generic (list params)
  978. "Convert a LIST parsed through `org-list-parse-list' to other formats.
  979. Valid parameters PARAMS are
  980. :ustart String to start an unordered list
  981. :uend String to end an unordered list
  982. :ostart String to start an ordered list
  983. :oend String to end an ordered list
  984. :dstart String to start a descriptive list
  985. :dend String to end a descriptive list
  986. :dtstart String to start a descriptive term
  987. :dtend String to end a descriptive term
  988. :ddstart String to start a description
  989. :ddend String to end a description
  990. :splice When set to t, return only list body lines, don't wrap
  991. them into :[u/o]start and :[u/o]end. Default is nil.
  992. :istart String to start a list item
  993. :iend String to end a list item
  994. :isep String to separate items
  995. :lsep String to separate sublists
  996. :cboff String to insert for an unchecked checkbox
  997. :cbon String to insert for a checked checkbox"
  998. (interactive)
  999. (let* ((p params) sublist
  1000. (splicep (plist-get p :splice))
  1001. (ostart (plist-get p :ostart))
  1002. (oend (plist-get p :oend))
  1003. (ustart (plist-get p :ustart))
  1004. (uend (plist-get p :uend))
  1005. (dstart (plist-get p :dstart))
  1006. (dend (plist-get p :dend))
  1007. (dtstart (plist-get p :dtstart))
  1008. (dtend (plist-get p :dtend))
  1009. (ddstart (plist-get p :ddstart))
  1010. (ddend (plist-get p :ddend))
  1011. (istart (plist-get p :istart))
  1012. (iend (plist-get p :iend))
  1013. (isep (plist-get p :isep))
  1014. (lsep (plist-get p :lsep))
  1015. (cbon (plist-get p :cbon))
  1016. (cboff (plist-get p :cboff)))
  1017. (let ((wrapper
  1018. (cond ((eq (car list) 'ordered)
  1019. (concat ostart "\n%s" oend "\n"))
  1020. ((eq (car list) 'unordered)
  1021. (concat ustart "\n%s" uend "\n"))
  1022. ((eq (car list) 'descriptive)
  1023. (concat dstart "\n%s" dend "\n"))))
  1024. rtn term defstart defend)
  1025. (while (setq sublist (pop list))
  1026. (cond ((symbolp sublist) nil)
  1027. ((stringp sublist)
  1028. (when (string-match "^\\(.*\\) ::" sublist)
  1029. (setq term (org-trim (format (concat dtstart "%s" dtend)
  1030. (match-string 1 sublist))))
  1031. (setq sublist (substring sublist (1+ (length term)))))
  1032. (if (string-match "\\[CBON\\]" sublist)
  1033. (setq sublist (replace-match cbon t t sublist)))
  1034. (if (string-match "\\[CBOFF\\]" sublist)
  1035. (setq sublist (replace-match cboff t t sublist)))
  1036. (setq rtn (concat rtn istart term ddstart
  1037. sublist ddend iend isep)))
  1038. (t (setq rtn (concat rtn ;; previous list
  1039. lsep ;; list separator
  1040. (org-list-to-generic sublist p)
  1041. lsep ;; list separator
  1042. )))))
  1043. (format wrapper rtn))))
  1044. (defun org-list-to-latex (list &optional params)
  1045. "Convert LIST into a LaTeX list.
  1046. LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
  1047. with overruling parameters for `org-list-to-generic'."
  1048. (org-list-to-generic
  1049. list
  1050. (org-combine-plists
  1051. '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
  1052. :ustart "\\begin{itemize}" :uend "\\end{itemize}"
  1053. :dstart "\\begin{description}" :dend "\\end{description}"
  1054. :dtstart "[" :dtend "]"
  1055. :ddstart "" :ddend ""
  1056. :istart "\\item " :iend ""
  1057. :isep "\n" :lsep "\n"
  1058. :cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}")
  1059. params)))
  1060. (defun org-list-to-html (list &optional params)
  1061. "Convert LIST into a HTML list.
  1062. LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
  1063. with overruling parameters for `org-list-to-generic'."
  1064. (org-list-to-generic
  1065. list
  1066. (org-combine-plists
  1067. '(:splicep nil :ostart "<ol>" :oend "</ol>"
  1068. :ustart "<ul>" :uend "</ul>"
  1069. :dstart "<dl>" :dend "</dl>"
  1070. :dtstart "<dt>" :dtend "</dt>"
  1071. :ddstart "<dd>" :ddend "</dd>"
  1072. :istart "<li>" :iend "</li>"
  1073. :isep "\n" :lsep "\n"
  1074. :cbon "<code>[X]</code>" :cboff "<code>[ ]</code>")
  1075. params)))
  1076. (defun org-list-to-texinfo (list &optional params)
  1077. "Convert LIST into a Texinfo list.
  1078. LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
  1079. with overruling parameters for `org-list-to-generic'."
  1080. (org-list-to-generic
  1081. list
  1082. (org-combine-plists
  1083. '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
  1084. :ustart "@enumerate" :uend "@end enumerate"
  1085. :dstart "@table" :dend "@end table"
  1086. :dtstart "@item " :dtend "\n"
  1087. :ddstart "" :ddend ""
  1088. :istart "@item\n" :iend ""
  1089. :isep "\n" :lsep "\n"
  1090. :cbon "@code{[X]}" :cboff "@code{[ ]}")
  1091. params)))
  1092. (provide 'org-list)
  1093. ;; arch-tag: 73cf50c1-200f-4d1d-8a53-4e842a5b11c8
  1094. ;;; org-list.el ends here