org-list.el 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  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.22b
  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. When there is an active region, toggle status or presence of the checkbox
  229. in the first line, and make every item in the region have the same
  230. status or presence, respectively.
  231. If the cursor is in a headline, apply this to all checkbox items in the
  232. text below the heading."
  233. (interactive "P")
  234. (catch 'exit
  235. (let (beg end status first-present first-status)
  236. (cond
  237. ((org-region-active-p)
  238. (setq beg (region-beginning) end (region-end)))
  239. ((org-on-heading-p)
  240. (setq beg (point) end (save-excursion (outline-next-heading) (point))))
  241. ((org-at-item-checkbox-p)
  242. (let ((pos (point)))
  243. (if toggle-presence
  244. (progn
  245. (replace-match "")
  246. (goto-char (match-beginning 0))
  247. (just-one-space))
  248. (replace-match
  249. (cond ((member (match-string 0) '("[ ]" "[-]")) "[X]")
  250. (t "[ ]"))
  251. t t))
  252. (goto-char pos))
  253. (throw 'exit t))
  254. ((org-at-item-p)
  255. ;; add a checkbox
  256. (save-excursion
  257. (goto-char (match-end 0))
  258. (insert "[ ] "))
  259. (throw 'exit t))
  260. (t (error "Not at a checkbox or heading, and no active region")))
  261. (setq end (move-marker (make-marker) end))
  262. (save-excursion
  263. (goto-char beg)
  264. (setq first-present (org-at-item-checkbox-p)
  265. first-status
  266. (save-excursion
  267. (and (re-search-forward "[ \t]\\(\\[[ X]\\]\\)" end t)
  268. (equal (match-string 1) "[X]"))))
  269. (while (< (point) end)
  270. (if toggle-presence
  271. (cond
  272. ((and first-present (org-at-item-checkbox-p))
  273. (save-excursion
  274. (replace-match "")
  275. (goto-char (match-beginning 0))
  276. (just-one-space)))
  277. ((and (not first-present) (not (org-at-item-checkbox-p))
  278. (org-at-item-p))
  279. (save-excursion
  280. (goto-char (match-end 0))
  281. (insert "[ ] "))))
  282. (when (org-at-item-checkbox-p)
  283. (setq status (equal (match-string 0) "[X]"))
  284. (replace-match
  285. (if first-status "[ ]" "[X]") t t)))
  286. (beginning-of-line 2)))))
  287. (org-update-checkbox-count-maybe))
  288. (defun org-update-checkbox-count-maybe ()
  289. "Update checkbox statistics unless turned off by user."
  290. (when org-provide-checkbox-statistics
  291. (org-update-checkbox-count)))
  292. (defun org-update-checkbox-count (&optional all)
  293. "Update the checkbox statistics in the current section.
  294. This will find all statistic cookies like [57%] and [6/12] and update them
  295. with the current numbers. With optional prefix argument ALL, do this for
  296. the whole buffer."
  297. (interactive "P")
  298. (save-excursion
  299. (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
  300. (beg (condition-case nil
  301. (progn (org-back-to-heading) (point))
  302. (error (point-min))))
  303. (end (move-marker (make-marker)
  304. (progn (outline-next-heading) (point))))
  305. (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
  306. (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
  307. (re-find (concat re "\\|" re-box))
  308. beg-cookie end-cookie is-percent c-on c-off lim
  309. eline curr-ind next-ind continue-from startsearch
  310. (cstat 0)
  311. )
  312. (when all
  313. (goto-char (point-min))
  314. (outline-next-heading)
  315. (setq beg (point) end (point-max)))
  316. (goto-char end)
  317. ;; find each statistic cookie
  318. (while (re-search-backward re-find beg t)
  319. (setq beg-cookie (match-beginning 1)
  320. end-cookie (match-end 1)
  321. cstat (+ cstat (if end-cookie 1 0))
  322. startsearch (point-at-eol)
  323. continue-from (match-beginning 0)
  324. is-percent (match-beginning 2)
  325. lim (cond
  326. ((org-on-heading-p) (outline-next-heading) (point))
  327. ((org-at-item-p) (org-end-of-item) (point))
  328. (t nil))
  329. c-on 0
  330. c-off 0)
  331. (when lim
  332. ;; find first checkbox for this cookie and gather
  333. ;; statistics from all that are at this indentation level
  334. (goto-char startsearch)
  335. (if (re-search-forward re-box lim t)
  336. (progn
  337. (org-beginning-of-item)
  338. (setq curr-ind (org-get-indentation))
  339. (setq next-ind curr-ind)
  340. (while (and (bolp) (org-at-item-p) (= curr-ind next-ind))
  341. (save-excursion (end-of-line) (setq eline (point)))
  342. (if (re-search-forward re-box eline t)
  343. (if (member (match-string 2) '("[ ]" "[-]"))
  344. (setq c-off (1+ c-off))
  345. (setq c-on (1+ c-on))
  346. )
  347. )
  348. (org-end-of-item)
  349. (setq next-ind (org-get-indentation))
  350. )))
  351. (goto-char continue-from)
  352. ;; update cookie
  353. (when end-cookie
  354. (delete-region beg-cookie end-cookie)
  355. (goto-char beg-cookie)
  356. (insert
  357. (if is-percent
  358. (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
  359. (format "[%d/%d]" c-on (+ c-on c-off)))))
  360. ;; update items checkbox if it has one
  361. (when (org-at-item-p)
  362. (org-beginning-of-item)
  363. (when (and (> (+ c-on c-off) 0)
  364. (re-search-forward re-box (point-at-eol) t))
  365. (setq beg-cookie (match-beginning 2)
  366. end-cookie (match-end 2))
  367. (delete-region beg-cookie end-cookie)
  368. (goto-char beg-cookie)
  369. (cond ((= c-off 0) (insert "[X]"))
  370. ((= c-on 0) (insert "[ ]"))
  371. (t (insert "[-]")))
  372. )))
  373. (goto-char continue-from))
  374. (when (interactive-p)
  375. (message "Checkbox statistics updated %s (%d places)"
  376. (if all "in entire file" "in current outline entry") cstat)))))
  377. (defun org-get-checkbox-statistics-face ()
  378. "Select the face for checkbox statistics.
  379. The face will be `org-done' when all relevant boxes are checked. Otherwise
  380. it will be `org-todo'."
  381. (if (match-end 1)
  382. (if (equal (match-string 1) "100%") 'org-done 'org-todo)
  383. (if (and (> (match-end 2) (match-beginning 2))
  384. (equal (match-string 2) (match-string 3)))
  385. 'org-done
  386. 'org-todo)))
  387. (defun org-beginning-of-item ()
  388. "Go to the beginning of the current hand-formatted item.
  389. If the cursor is not in an item, throw an error."
  390. (interactive)
  391. (let ((pos (point))
  392. (limit (save-excursion
  393. (condition-case nil
  394. (progn
  395. (org-back-to-heading)
  396. (beginning-of-line 2) (point))
  397. (error (point-min)))))
  398. (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
  399. ind ind1)
  400. (if (org-at-item-p)
  401. (beginning-of-line 1)
  402. (beginning-of-line 1)
  403. (skip-chars-forward " \t")
  404. (setq ind (current-column))
  405. (if (catch 'exit
  406. (while t
  407. (beginning-of-line 0)
  408. (if (or (bobp) (< (point) limit)) (throw 'exit nil))
  409. (if (looking-at "[ \t]*$")
  410. (setq ind1 ind-empty)
  411. (skip-chars-forward " \t")
  412. (setq ind1 (current-column)))
  413. (if (< ind1 ind)
  414. (progn (beginning-of-line 1) (throw 'exit (org-at-item-p))))))
  415. nil
  416. (goto-char pos)
  417. (error "Not in an item")))))
  418. (defun org-end-of-item ()
  419. "Go to the end of the current hand-formatted item.
  420. If the cursor is not in an item, throw an error."
  421. (interactive)
  422. (let* ((pos (point))
  423. ind1
  424. (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
  425. (limit (save-excursion (outline-next-heading) (point)))
  426. (ind (save-excursion
  427. (org-beginning-of-item)
  428. (skip-chars-forward " \t")
  429. (current-column)))
  430. (end (catch 'exit
  431. (while t
  432. (beginning-of-line 2)
  433. (if (eobp) (throw 'exit (point)))
  434. (if (>= (point) limit) (throw 'exit (point-at-bol)))
  435. (if (looking-at "[ \t]*$")
  436. (setq ind1 ind-empty)
  437. (skip-chars-forward " \t")
  438. (setq ind1 (current-column)))
  439. (if (<= ind1 ind)
  440. (throw 'exit (point-at-bol)))))))
  441. (if end
  442. (goto-char end)
  443. (goto-char pos)
  444. (error "Not in an item"))))
  445. (defun org-next-item ()
  446. "Move to the beginning of the next item in the current plain list.
  447. Error if not at a plain list, or if this is the last item in the list."
  448. (interactive)
  449. (let (ind ind1 (pos (point)))
  450. (org-beginning-of-item)
  451. (setq ind (org-get-indentation))
  452. (org-end-of-item)
  453. (setq ind1 (org-get-indentation))
  454. (unless (and (org-at-item-p) (= ind ind1))
  455. (goto-char pos)
  456. (error "On last item"))))
  457. (defun org-previous-item ()
  458. "Move to the beginning of the previous item in the current plain list.
  459. Error if not at a plain list, or if this is the first item in the list."
  460. (interactive)
  461. (let (beg ind ind1 (pos (point)))
  462. (org-beginning-of-item)
  463. (setq beg (point))
  464. (setq ind (org-get-indentation))
  465. (goto-char beg)
  466. (catch 'exit
  467. (while t
  468. (beginning-of-line 0)
  469. (if (looking-at "[ \t]*$")
  470. nil
  471. (if (<= (setq ind1 (org-get-indentation)) ind)
  472. (throw 'exit t)))))
  473. (condition-case nil
  474. (if (or (not (org-at-item-p))
  475. (< ind1 (1- ind)))
  476. (error "")
  477. (org-beginning-of-item))
  478. (error (goto-char pos)
  479. (error "On first item")))))
  480. (defun org-first-list-item-p ()
  481. "Is this heading the item in a plain list?"
  482. (unless (org-at-item-p)
  483. (error "Not at a plain list item"))
  484. (org-beginning-of-item)
  485. (= (point) (save-excursion (org-beginning-of-item-list))))
  486. (defun org-move-item-down ()
  487. "Move the plain list item at point down, i.e. swap with following item.
  488. Subitems (items with larger indentation) are considered part of the item,
  489. so this really moves item trees."
  490. (interactive)
  491. (let ((col (current-column))
  492. (pos (point))
  493. beg beg0 end end0 ind ind1 txt ne-end ne-beg)
  494. (org-beginning-of-item)
  495. (setq beg0 (point))
  496. (save-excursion
  497. (setq ne-beg (org-back-over-empty-lines))
  498. (setq beg (point)))
  499. (goto-char beg0)
  500. (setq ind (org-get-indentation))
  501. (org-end-of-item)
  502. (setq end0 (point))
  503. (setq ind1 (org-get-indentation))
  504. (setq ne-end (org-back-over-empty-lines))
  505. (setq end (point))
  506. (goto-char beg0)
  507. (when (and (org-first-list-item-p) (< ne-end ne-beg))
  508. ;; include less whitespace
  509. (save-excursion
  510. (goto-char beg)
  511. (forward-line (- ne-beg ne-end))
  512. (setq beg (point))))
  513. (goto-char end0)
  514. (if (and (org-at-item-p) (= ind ind1))
  515. (progn
  516. (org-end-of-item)
  517. (org-back-over-empty-lines)
  518. (setq txt (buffer-substring beg end))
  519. (save-excursion
  520. (delete-region beg end))
  521. (setq pos (point))
  522. (insert txt)
  523. (goto-char pos) (org-skip-whitespace)
  524. (org-maybe-renumber-ordered-list)
  525. (move-to-column col))
  526. (goto-char pos)
  527. (move-to-column col)
  528. (error "Cannot move this item further down"))))
  529. (defun org-move-item-up (arg)
  530. "Move the plain list item at point up, i.e. swap with previous item.
  531. Subitems (items with larger indentation) are considered part of the item,
  532. so this really moves item trees."
  533. (interactive "p")
  534. (let ((col (current-column)) (pos (point))
  535. beg beg0 end ind ind1 txt
  536. ne-beg ne-ins ins-end)
  537. (org-beginning-of-item)
  538. (setq beg0 (point))
  539. (setq ind (org-get-indentation))
  540. (save-excursion
  541. (setq ne-beg (org-back-over-empty-lines))
  542. (setq beg (point)))
  543. (goto-char beg0)
  544. (org-end-of-item)
  545. (org-back-over-empty-lines)
  546. (setq end (point))
  547. (goto-char beg0)
  548. (catch 'exit
  549. (while t
  550. (beginning-of-line 0)
  551. (if (looking-at "[ \t]*$")
  552. (if org-empty-line-terminates-plain-lists
  553. (progn
  554. (goto-char pos)
  555. (error "Cannot move this item further up"))
  556. nil)
  557. (if (<= (setq ind1 (org-get-indentation)) ind)
  558. (throw 'exit t)))))
  559. (condition-case nil
  560. (org-beginning-of-item)
  561. (error (goto-char beg0)
  562. (move-to-column col)
  563. (error "Cannot move this item further up")))
  564. (setq ind1 (org-get-indentation))
  565. (if (and (org-at-item-p) (= ind ind1))
  566. (progn
  567. (setq ne-ins (org-back-over-empty-lines))
  568. (setq txt (buffer-substring beg end))
  569. (save-excursion
  570. (delete-region beg end))
  571. (setq pos (point))
  572. (insert txt)
  573. (setq ins-end (point))
  574. (goto-char pos) (org-skip-whitespace)
  575. (when (and (org-first-list-item-p) (> ne-ins ne-beg))
  576. ;; Move whitespace back to beginning
  577. (save-excursion
  578. (goto-char ins-end)
  579. (let ((kill-whole-line t))
  580. (kill-line (- ne-ins ne-beg)) (point)))
  581. (insert (make-string (- ne-ins ne-beg) ?\n)))
  582. (org-maybe-renumber-ordered-list)
  583. (move-to-column col))
  584. (goto-char pos)
  585. (move-to-column col)
  586. (error "Cannot move this item further up"))))
  587. (defun org-maybe-renumber-ordered-list ()
  588. "Renumber the ordered list at point if setup allows it.
  589. This tests the user option `org-auto-renumber-ordered-lists' before
  590. doing the renumbering."
  591. (interactive)
  592. (when (and org-auto-renumber-ordered-lists
  593. (org-at-item-p))
  594. (if (match-beginning 3)
  595. (org-renumber-ordered-list 1)
  596. (org-fix-bullet-type))))
  597. (defun org-maybe-renumber-ordered-list-safe ()
  598. (condition-case nil
  599. (save-excursion
  600. (org-maybe-renumber-ordered-list))
  601. (error nil)))
  602. (defun org-cycle-list-bullet (&optional which)
  603. "Cycle through the different itemize/enumerate bullets.
  604. This cycle the entire list level through the sequence:
  605. `-' -> `+' -> `*' -> `1.' -> `1)'
  606. If WHICH is a string, use that as the new bullet. If WHICH is an integer,
  607. 0 means `-', 1 means `+' etc."
  608. (interactive "P")
  609. (org-preserve-lc
  610. (org-beginning-of-item-list)
  611. (org-at-item-p)
  612. (beginning-of-line 1)
  613. (let ((current (match-string 0))
  614. (prevp (eq which 'previous))
  615. new old)
  616. (setq new (cond
  617. ((and (numberp which)
  618. (nth (1- which) '("-" "+" "*" "1." "1)"))))
  619. ((string-match "-" current) (if prevp "1)" "+"))
  620. ((string-match "\\+" current)
  621. (if prevp "-" (if (looking-at "\\S-") "1." "*")))
  622. ((string-match "\\*" current) (if prevp "+" "1."))
  623. ((string-match "\\." current)
  624. (if prevp (if (looking-at "\\S-") "+" "*") "1)"))
  625. ((string-match ")" current) (if prevp "1." "-"))
  626. (t (error "This should not happen"))))
  627. (and (looking-at "\\([ \t]*\\)\\(\\S-+\\)")
  628. (setq old (match-string 2))
  629. (replace-match (concat "\\1" new)))
  630. (org-shift-item-indentation (- (length new) (length old)))
  631. (org-fix-bullet-type)
  632. (org-maybe-renumber-ordered-list))))
  633. (defun org-get-string-indentation (s)
  634. "What indentation has S due to SPACE and TAB at the beginning of the string?"
  635. (let ((n -1) (i 0) (w tab-width) c)
  636. (catch 'exit
  637. (while (< (setq n (1+ n)) (length s))
  638. (setq c (aref s n))
  639. (cond ((= c ?\ ) (setq i (1+ i)))
  640. ((= c ?\t) (setq i (* (/ (+ w i) w) w)))
  641. (t (throw 'exit t)))))
  642. i))
  643. (defun org-renumber-ordered-list (arg)
  644. "Renumber an ordered plain list.
  645. Cursor needs to be in the first line of an item, the line that starts
  646. with something like \"1.\" or \"2)\"."
  647. (interactive "p")
  648. (unless (and (org-at-item-p)
  649. (match-beginning 3))
  650. (error "This is not an ordered list"))
  651. (let ((line (org-current-line))
  652. (col (current-column))
  653. (ind (org-get-string-indentation
  654. (buffer-substring (point-at-bol) (match-beginning 3))))
  655. ;; (term (substring (match-string 3) -1))
  656. ind1 (n (1- arg))
  657. fmt bobp old new)
  658. ;; find where this list begins
  659. (org-beginning-of-item-list)
  660. (setq bobp (bobp))
  661. (looking-at "[ \t]*[0-9]+\\([.)]\\)")
  662. (setq fmt (concat "%d" (match-string 1)))
  663. (beginning-of-line 0)
  664. ;; walk forward and replace these numbers
  665. (catch 'exit
  666. (while t
  667. (catch 'next
  668. (if bobp (setq bobp nil) (beginning-of-line 2))
  669. (if (eobp) (throw 'exit nil))
  670. (if (looking-at "[ \t]*$") (throw 'next nil))
  671. (skip-chars-forward " \t") (setq ind1 (current-column))
  672. (if (> ind1 ind) (throw 'next t))
  673. (if (< ind1 ind) (throw 'exit t))
  674. (if (not (org-at-item-p)) (throw 'exit nil))
  675. (setq old (match-string 2))
  676. (delete-region (match-beginning 2) (match-end 2))
  677. (goto-char (match-beginning 2))
  678. (insert (setq new (format fmt (setq n (1+ n)))))
  679. (org-shift-item-indentation (- (length new) (length old))))))
  680. (goto-line line)
  681. (org-move-to-column col)))
  682. (defun org-fix-bullet-type ()
  683. "Make sure all items in this list have the same bullet as the first item.
  684. Also, fix the indentation."
  685. (interactive)
  686. (unless (org-at-item-p) (error "This is not a list"))
  687. (let ((line (org-current-line))
  688. (col (current-column))
  689. (ind (current-indentation))
  690. ind1 bullet oldbullet)
  691. ;; find where this list begins
  692. (org-beginning-of-item-list)
  693. (beginning-of-line 1)
  694. ;; find out what the bullet type is
  695. (looking-at "[ \t]*\\(\\S-+\\)")
  696. (setq bullet (concat (match-string 1) " "))
  697. (if (and org-list-two-spaces-after-bullet-regexp
  698. (string-match org-list-two-spaces-after-bullet-regexp bullet))
  699. (setq bullet (concat bullet " ")))
  700. ;; walk forward and replace these numbers
  701. (beginning-of-line 0)
  702. (catch 'exit
  703. (while t
  704. (catch 'next
  705. (beginning-of-line 2)
  706. (if (eobp) (throw 'exit nil))
  707. (if (looking-at "[ \t]*$") (throw 'next nil))
  708. (skip-chars-forward " \t") (setq ind1 (current-column))
  709. (if (> ind1 ind) (throw 'next t))
  710. (if (< ind1 ind) (throw 'exit t))
  711. (if (not (org-at-item-p)) (throw 'exit nil))
  712. (skip-chars-forward " \t")
  713. (looking-at "\\S-+ *")
  714. (setq oldbullet (match-string 0))
  715. (replace-match bullet)
  716. (org-shift-item-indentation (- (length bullet) (length oldbullet))))))
  717. (goto-line line)
  718. (org-move-to-column col)
  719. (if (string-match "[0-9]" bullet)
  720. (org-renumber-ordered-list 1))))
  721. (defun org-shift-item-indentation (delta)
  722. "Shift the indentation in current item by DELTA."
  723. (save-excursion
  724. (let ((beg (point-at-bol))
  725. (end (progn (org-end-of-item) (point)))
  726. i)
  727. (goto-char end)
  728. (beginning-of-line 0)
  729. (while (> (point) beg)
  730. (when (looking-at "[ \t]*\\S-")
  731. ;; this is not an empty line
  732. (setq i (org-get-indentation))
  733. (if (and (> i 0) (> (setq i (+ i delta)) 0))
  734. (indent-line-to i)))
  735. (beginning-of-line 0)))))
  736. (defun org-beginning-of-item-list ()
  737. "Go to the beginning of the current item list.
  738. I.e. to the first item in this list."
  739. (interactive)
  740. (org-beginning-of-item)
  741. (let ((pos (point-at-bol))
  742. (ind (org-get-indentation))
  743. ind1)
  744. ;; find where this list begins
  745. (catch 'exit
  746. (while t
  747. (catch 'next
  748. (beginning-of-line 0)
  749. (if (looking-at "[ \t]*$")
  750. (throw (if (bobp) 'exit 'next) t))
  751. (skip-chars-forward " \t") (setq ind1 (current-column))
  752. (if (or (< ind1 ind)
  753. (and (= ind1 ind)
  754. (not (org-at-item-p)))
  755. (and (= (point-at-bol) (point-min))
  756. (setq pos (point-min))))
  757. (throw 'exit t)
  758. (when (org-at-item-p) (setq pos (point-at-bol)))))))
  759. (goto-char pos)))
  760. (defun org-end-of-item-list ()
  761. "Go to the end of the current item list.
  762. I.e. to the text after the last item."
  763. (interactive)
  764. (org-beginning-of-item)
  765. (let ((pos (point-at-bol))
  766. (ind (org-get-indentation))
  767. ind1)
  768. ;; find where this list begins
  769. (catch 'exit
  770. (while t
  771. (catch 'next
  772. (beginning-of-line 2)
  773. (if (looking-at "[ \t]*$")
  774. (throw (if (eobp) 'exit 'next) t))
  775. (skip-chars-forward " \t") (setq ind1 (current-column))
  776. (if (or (< ind1 ind)
  777. (and (= ind1 ind)
  778. (not (org-at-item-p)))
  779. (eobp))
  780. (progn
  781. (setq pos (point-at-bol))
  782. (throw 'exit t))))))
  783. (goto-char pos)))
  784. (defvar org-last-indent-begin-marker (make-marker))
  785. (defvar org-last-indent-end-marker (make-marker))
  786. (defun org-outdent-item (arg)
  787. "Outdent a local list item."
  788. (interactive "p")
  789. (org-indent-item (- arg)))
  790. (defun org-indent-item (arg)
  791. "Indent a local list item."
  792. (interactive "p")
  793. (unless (org-at-item-p)
  794. (error "Not on an item"))
  795. (save-excursion
  796. (let (beg end ind ind1 tmp delta ind-down ind-up)
  797. (if (memq last-command '(org-shiftmetaright org-shiftmetaleft))
  798. (setq beg org-last-indent-begin-marker
  799. end org-last-indent-end-marker)
  800. (org-beginning-of-item)
  801. (setq beg (move-marker org-last-indent-begin-marker (point)))
  802. (org-end-of-item)
  803. (setq end (move-marker org-last-indent-end-marker (point))))
  804. (goto-char beg)
  805. (setq tmp (org-item-indent-positions)
  806. ind (car tmp)
  807. ind-down (nth 2 tmp)
  808. ind-up (nth 1 tmp)
  809. delta (if (> arg 0)
  810. (if ind-down (- ind-down ind) 2)
  811. (if ind-up (- ind-up ind) -2)))
  812. (if (< (+ delta ind) 0) (error "Cannot outdent beyond margin"))
  813. (while (< (point) end)
  814. (beginning-of-line 1)
  815. (skip-chars-forward " \t") (setq ind1 (current-column))
  816. (delete-region (point-at-bol) (point))
  817. (or (eolp) (org-indent-to-column (+ ind1 delta)))
  818. (beginning-of-line 2))))
  819. (org-fix-bullet-type)
  820. (org-maybe-renumber-ordered-list-safe)
  821. (save-excursion
  822. (beginning-of-line 0)
  823. (condition-case nil (org-beginning-of-item) (error nil))
  824. (org-maybe-renumber-ordered-list-safe)))
  825. (defun org-item-indent-positions ()
  826. "Return indentation for plain list items.
  827. This returns a list with three values: The current indentation, the
  828. parent indentation and the indentation a child should have.
  829. Assumes cursor in item line."
  830. (let* ((bolpos (point-at-bol))
  831. (ind (org-get-indentation))
  832. ind-down ind-up pos)
  833. (save-excursion
  834. (org-beginning-of-item-list)
  835. (skip-chars-backward "\n\r \t")
  836. (when (org-in-item-p)
  837. (org-beginning-of-item)
  838. (setq ind-up (org-get-indentation))))
  839. (setq pos (point))
  840. (save-excursion
  841. (cond
  842. ((and (condition-case nil (progn (org-previous-item) t)
  843. (error nil))
  844. (or (forward-char 1) t)
  845. (re-search-forward "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)" bolpos t))
  846. (setq ind-down (org-get-indentation)))
  847. ((and (goto-char pos)
  848. (org-at-item-p))
  849. (goto-char (match-end 0))
  850. (skip-chars-forward " \t")
  851. (setq ind-down (current-column)))))
  852. (list ind ind-up ind-down)))
  853. ;;; Send and receive lists
  854. (defun org-list-parse-list (&optional delete)
  855. "Parse the list at point and maybe DELETE it.
  856. Return a list containing first level items as strings and
  857. sublevels as a list of strings."
  858. (let* ((item-beginning (org-list-item-beginning))
  859. (start (car item-beginning))
  860. (end (org-list-end (cdr item-beginning)))
  861. output itemsep ltype)
  862. (while (re-search-forward org-list-beginning-re end t)
  863. (goto-char (match-beginning 3))
  864. (save-match-data
  865. (cond ((string-match "[0-9]" (match-string 2))
  866. (setq itemsep "[0-9]+\\(?:\\.\\|)\\)"
  867. ltype 'ordered))
  868. ((string-match "^.*::" (match-string 0))
  869. (setq itemsep "[-+]" ltype 'descriptive))
  870. (t (setq itemsep "[-+]" ltype 'unordered))))
  871. (let* ((indent1 (match-string 1))
  872. (nextitem (save-excursion
  873. (save-match-data
  874. (or (and (re-search-forward
  875. (concat "^" indent1 itemsep " *?") end t)
  876. (match-beginning 0)) end))))
  877. (item (buffer-substring
  878. (point)
  879. (or (and (re-search-forward
  880. org-list-beginning-re end t)
  881. (goto-char (match-beginning 0)))
  882. (goto-char end))))
  883. (nextindent (match-string 1))
  884. (item (org-trim item))
  885. (item (if (string-match "^\\[\\([xX ]\\)\\]" item)
  886. (replace-match (if (equal (match-string 1 item) " ")
  887. "[CBOFF]"
  888. "[CBON]")
  889. t nil item)
  890. item)))
  891. (push item output)
  892. (when (> (length nextindent)
  893. (length indent1))
  894. (narrow-to-region (point) nextitem)
  895. (push (org-list-parse-list) output)
  896. (widen))))
  897. (when delete (delete-region start end))
  898. (setq output (nreverse output))
  899. (push ltype output)))
  900. (defun org-list-item-beginning ()
  901. "Find the beginning of the list item.
  902. Return a cons which car is the beginning position of the item and
  903. cdr is the indentation string."
  904. (save-excursion
  905. (if (not (or (looking-at org-list-beginning-re)
  906. (re-search-backward
  907. org-list-beginning-re nil t)))
  908. (progn (goto-char (point-min)) (point))
  909. (cons (match-beginning 0) (match-string 1)))))
  910. (defun org-list-end (indent)
  911. "Return the position of the end of the list.
  912. INDENT is the indentation of the list."
  913. (save-excursion
  914. (catch 'exit
  915. (while (or (looking-at org-list-beginning-re)
  916. (looking-at (concat "^" indent "[ \t]+\\|^$")))
  917. (if (eq (point) (point-max))
  918. (throw 'exit (point-max)))
  919. (forward-line 1))) (point)))
  920. (defun org-list-insert-radio-list ()
  921. "Insert a radio list template appropriate for this major mode."
  922. (interactive)
  923. (let* ((e (assq major-mode org-list-radio-list-templates))
  924. (txt (nth 1 e))
  925. name pos)
  926. (unless e (error "No radio list setup defined for %s" major-mode))
  927. (setq name (read-string "List name: "))
  928. (while (string-match "%n" txt)
  929. (setq txt (replace-match name t t txt)))
  930. (or (bolp) (insert "\n"))
  931. (setq pos (point))
  932. (insert txt)
  933. (goto-char pos)))
  934. (defun org-list-send-list (&optional maybe)
  935. "Send a tranformed version of this list to the receiver position.
  936. With argument MAYBE, fail quietly if no transformation is defined for
  937. this list."
  938. (interactive)
  939. (catch 'exit
  940. (unless (org-at-item-p) (error "Not at a list"))
  941. (save-excursion
  942. (goto-char (car (org-list-item-beginning)))
  943. (beginning-of-line 0)
  944. (unless (looking-at "#\\+ORGLST: *SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
  945. (if maybe
  946. (throw 'exit nil)
  947. (error "Don't know how to transform this list"))))
  948. (let* ((name (match-string 1))
  949. (item-beginning (org-list-item-beginning))
  950. (transform (intern (match-string 2)))
  951. (txt (buffer-substring-no-properties
  952. (car item-beginning)
  953. (org-list-end (cdr item-beginning))))
  954. (list (org-list-parse-list))
  955. beg)
  956. (unless (fboundp transform)
  957. (error "No such transformation function %s" transform))
  958. (setq txt (funcall transform list))
  959. ;; Find the insertion place
  960. (save-excursion
  961. (goto-char (point-min))
  962. (unless (re-search-forward
  963. (concat "BEGIN RECEIVE ORGLST +" name "\\([ \t]\\|$\\)") nil t)
  964. (error "Don't know where to insert translated list"))
  965. (goto-char (match-beginning 0))
  966. (beginning-of-line 2)
  967. (setq beg (point))
  968. (unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t)
  969. (error "Cannot find end of insertion region"))
  970. (beginning-of-line 1)
  971. (delete-region beg (point))
  972. (goto-char beg)
  973. (insert txt "\n"))
  974. (message "List converted and installed at receiver location"))))
  975. (defun org-list-to-generic (list params)
  976. "Convert a LIST parsed through `org-list-parse-list' to other formats.
  977. Valid parameters PARAMS are
  978. :ustart String to start an unordered list
  979. :uend String to end an unordered list
  980. :ostart String to start an ordered list
  981. :oend String to end an ordered list
  982. :dstart String to start a descriptive list
  983. :dend String to end a descriptive list
  984. :dtstart String to start a descriptive term
  985. :dtend String to end a descriptive term
  986. :ddstart String to start a description
  987. :ddend String to end a description
  988. :splice When set to t, return only list body lines, don't wrap
  989. them into :[u/o]start and :[u/o]end. Default is nil.
  990. :istart String to start a list item
  991. :iend String to end a list item
  992. :isep String to separate items
  993. :lsep String to separate sublists
  994. :cboff String to insert for an unchecked checkbox
  995. :cbon String to insert for a checked checkbox"
  996. (interactive)
  997. (let* ((p params) sublist
  998. (splicep (plist-get p :splice))
  999. (ostart (plist-get p :ostart))
  1000. (oend (plist-get p :oend))
  1001. (ustart (plist-get p :ustart))
  1002. (uend (plist-get p :uend))
  1003. (dstart (plist-get p :dstart))
  1004. (dend (plist-get p :dend))
  1005. (dtstart (plist-get p :dtstart))
  1006. (dtend (plist-get p :dtend))
  1007. (ddstart (plist-get p :ddstart))
  1008. (ddend (plist-get p :ddend))
  1009. (istart (plist-get p :istart))
  1010. (iend (plist-get p :iend))
  1011. (isep (plist-get p :isep))
  1012. (lsep (plist-get p :lsep))
  1013. (cbon (plist-get p :cbon))
  1014. (cboff (plist-get p :cboff)))
  1015. (let ((wrapper
  1016. (cond ((eq (car list) 'ordered)
  1017. (concat ostart "\n%s" oend "\n"))
  1018. ((eq (car list) 'unordered)
  1019. (concat ustart "\n%s" uend "\n"))
  1020. ((eq (car list) 'descriptive)
  1021. (concat dstart "\n%s" dend "\n"))))
  1022. rtn term defstart defend)
  1023. (while (setq sublist (pop list))
  1024. (cond ((symbolp sublist) nil)
  1025. ((stringp sublist)
  1026. (when (string-match "^\\(.*\\) ::" sublist)
  1027. (setq term (org-trim (format (concat dtstart "%s" dtend)
  1028. (match-string 1 sublist))))
  1029. (setq sublist (substring sublist (1+ (length term)))))
  1030. (if (string-match "\\[CBON\\]" sublist)
  1031. (setq sublist (replace-match cbon t t sublist)))
  1032. (if (string-match "\\[CBOFF\\]" sublist)
  1033. (setq sublist (replace-match cboff t t sublist)))
  1034. (setq rtn (concat rtn istart term ddstart
  1035. sublist ddend iend isep)))
  1036. (t (setq rtn (concat rtn ;; previous list
  1037. lsep ;; list separator
  1038. (org-list-to-generic sublist p)
  1039. lsep ;; list separator
  1040. )))))
  1041. (format wrapper rtn))))
  1042. (defun org-list-to-latex (list &optional params)
  1043. "Convert LIST into a LaTeX list.
  1044. LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
  1045. with overruling parameters for `org-list-to-generic'."
  1046. (org-list-to-generic
  1047. list
  1048. (org-combine-plists
  1049. '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
  1050. :ustart "\\begin{itemize}" :uend "\\end{itemize}"
  1051. :dstart "\\begin{description}" :dend "\\end{description}"
  1052. :dtstart "[" :dtend "]"
  1053. :ddstart "" :ddend ""
  1054. :istart "\\item " :iend ""
  1055. :isep "\n" :lsep "\n"
  1056. :cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}")
  1057. params)))
  1058. (defun org-list-to-html (list &optional params)
  1059. "Convert LIST into a HTML list.
  1060. LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
  1061. with overruling parameters for `org-list-to-generic'."
  1062. (org-list-to-generic
  1063. list
  1064. (org-combine-plists
  1065. '(:splicep nil :ostart "<ol>" :oend "</ol>"
  1066. :ustart "<ul>" :uend "</ul>"
  1067. :dstart "<dl>" :dend "</dl>"
  1068. :dtstart "<dt>" :dtend "</dt>"
  1069. :ddstart "<dd>" :ddend "</dd>"
  1070. :istart "<li>" :iend "</li>"
  1071. :isep "\n" :lsep "\n"
  1072. :cbon "<code>[X]</code>" :cboff "<code>[ ]</code>")
  1073. params)))
  1074. (defun org-list-to-texinfo (list &optional params)
  1075. "Convert LIST into a Texinfo list.
  1076. LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
  1077. with overruling parameters for `org-list-to-generic'."
  1078. (org-list-to-generic
  1079. list
  1080. (org-combine-plists
  1081. '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
  1082. :ustart "@enumerate" :uend "@end enumerate"
  1083. :dstart "@table" :dend "@end table"
  1084. :dtstart "@item " :dtend "\n"
  1085. :ddstart "" :ddend ""
  1086. :istart "@item\n" :iend ""
  1087. :isep "\n" :lsep "\n"
  1088. :cbon "@code{[X]}" :cboff "@code{[ ]}")
  1089. params)))
  1090. (provide 'org-list)
  1091. ;; arch-tag: 73cf50c1-200f-4d1d-8a53-4e842a5b11c8
  1092. ;;; org-list.el ends here