annotate lisp/org/org-list.el @ 99866:57447f70a253

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