org-list.el 38 KB

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