org-list.el 38 KB

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