annotate lisp/org/org-list.el @ 100908:a9dc0e7c3f2b

Add 2009 to copyright years.
author Glenn Morris <rgm@gnu.org>
date Mon, 05 Jan 2009 03:18:22 +0000
parents 0d3c634e0bd9
children 36abe982e7cd
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 ;;
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100605
diff changeset
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
98645
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>
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
6 ;; Bastien Guerry <bzg AT altern DOT org>
98645
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
100605
0d3c634e0bd9 2008-12-20 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100458
diff changeset
9 ;; Version: 6.16
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
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98645
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))
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
48 (declare-function org-timer-item "org-timer" (&optional arg))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 (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
51 "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
52 :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
53 :group 'org-structure)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55 (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
56 "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
57 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
58 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
59 indentation of the bullet. In all other operations, plain list items are
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
60 not seen as headlines. For example, you cannot assign a TODO keyword to
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 such an item."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 :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
63 :type 'boolean)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 (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
66 "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
67 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
68 ?. 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
69 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
70 the safe choice."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 :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
72 :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
73 (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
74 (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
75
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
76 (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
77 "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
78 When nil, no bullet will have two spaces after them.
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
79 When a string, it will be used as a regular expression. When the bullet
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
80 type of a list is changed, the new bullet type will be matched against this
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
81 regexp. If it matches, there will be two spaces instead of one after
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
82 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
83 :group 'org-plain-list
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
84 :type '(choice
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
85 (const :tag "never" nil)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
86 (regexp)))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
87
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
88 (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
89 "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
90 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
91 :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
92 :type 'boolean)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94 (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
95 "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
96 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
97 \\[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
98 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
99 :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
100 :type 'boolean)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102 (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
103 "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
104 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
105 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
106 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
107 :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
108 :type 'boolean)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 (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
111 "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
112 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
113 5 characters instead."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 :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
115 :type 'integer)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 (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
118 "^\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) +\\(.*\\)$")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 (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
121 '((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
122 % 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
123 \\begin{comment}
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 #+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
125 | | |
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 \\end{comment}\n")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
127 (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
128 @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
129 @ignore
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
130 #+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
131 | | |
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 @end ignore\n")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 (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
134 <!-- 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
135 <!--
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 #+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
137 | | |
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 -->\n"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 "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
140 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
141 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
142 :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
143 :type '(repeat
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 (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
145 (string :tag "Format"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147 ;;;; 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
148
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149 ;;; Plain list items
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151 (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
152 "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
153 (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
154 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 (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
156 (looking-at
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 ((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
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 ((= 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
161 (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
162
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 (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
164 "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
165 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
166 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169 (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
170 (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
171 t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172 (error nil))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174 (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
175 "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
176 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
177 (when (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 (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
181 (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
182 (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
183 t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184 (error nil)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 (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
186 (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
187 (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
188 (save-match-data
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
189 (and (looking-at "[ \t]*\\(.*?\\) ::")
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
190 (match-string 1)))))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
191 (timerp (and descp
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
192 (save-match-data
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
193 (string-match "^[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+$"
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
194 descp))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 (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
196 (match-end 0)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 (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
198 pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 (if descp (setq checkbox nil))
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
200 (if timerp
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
201 (progn (org-timer-item) t)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
202 (cond
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
203 ((and (org-at-item-p) (<= (point) eow))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
204 ;; before the bullet
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
205 (beginning-of-line 1)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
206 (open-line (if blank 2 1)))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
207 ((<= (point) eow)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
208 (beginning-of-line 1))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
209 (t
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
210 (unless (org-get-alist-option org-M-RET-may-split-line 'item)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
211 (end-of-line 1)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
212 (delete-horizontal-space))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
213 (newline (if blank 2 1))))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
214 (insert bul
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
215 (if checkbox "[ ]" "")
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
216 (if descp (concat (if checkbox " " "")
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
217 (read-string "Term: ") " :: ") ""))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
218 (just-one-space)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
219 (setq pos (point))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
220 (end-of-line 1)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
221 (unless (= (point) pos) (just-one-space) (backward-delete-char 1)))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
222 (org-maybe-renumber-ordered-list)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
223 (and checkbox (org-update-checkbox-count-maybe))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
224 t)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 ;;; Checkboxes
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-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
229 "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
230 (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
231 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 (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
233 (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
234 (looking-at "\\[[- X]\\]"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
236 (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
237 "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
238 (interactive "P")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 (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
241 (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 ((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
243 (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
244 ((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
245 (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
246 ((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
247 (let ((pos (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
248 (replace-match
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
249 (cond (arg "[-]")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 ((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
251 (t "[ ]"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 t t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 (goto-char pos))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 (throw 'exit t))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255 (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
256 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 (goto-char beg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258 (while (< (point) end)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 (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
260 (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
261 (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
262 (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
263 (replace-match
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
264 (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
265 (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
266 (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
267
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
268 (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
269 "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
270 (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
271 (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
272
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273 (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
274 "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
275 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
276 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
277 the whole buffer."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278 (interactive "P")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
280 (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
281 (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
282 (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
283 (error (point-min))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284 (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
285 (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
286 (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
287 (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
288 (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
289 beg-cookie end-cookie is-percent c-on c-off lim
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
290 eline curr-ind next-ind continue-from startsearch
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
291 (cstat 0)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
292 )
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293 (when all
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 (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
295 (outline-next-heading)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 (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
297 (goto-char end)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298 ;; 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
299 (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
300 (setq beg-cookie (match-beginning 1)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
301 end-cookie (match-end 1)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302 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
303 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
304 continue-from (point-at-bol)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
305 is-percent (match-beginning 2)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
306 lim (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307 ((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
308 ((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
309 (t nil))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
310 c-on 0
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
311 c-off 0)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
312 (when lim
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
313 ;; find first checkbox for this cookie and gather
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
314 ;; statistics from all that are at this indentation level
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
315 (goto-char startsearch)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
316 (if (re-search-forward re-box lim t)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
317 (progn
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
318 (org-beginning-of-item)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
319 (setq curr-ind (org-get-indentation))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
320 (setq next-ind curr-ind)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
321 (while (and (bolp) (org-at-item-p) (= curr-ind next-ind))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
322 (save-excursion (end-of-line) (setq eline (point)))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
323 (if (re-search-forward re-box eline t)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
324 (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
325 (setq c-off (1+ c-off))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
326 (setq c-on (1+ c-on))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
327 )
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
328 )
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
329 (org-end-of-item)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
330 (setq next-ind (org-get-indentation))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
331 )))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332 (goto-char continue-from)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
333 ;; update cookie
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
334 (when end-cookie
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
335 (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
336 (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
337 (insert
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
338 (if is-percent
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
339 (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
340 (format "[%d/%d]" c-on (+ c-on c-off)))))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
341 ;; update items checkbox if it has one
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
342 (when (org-at-item-p)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
343 (org-beginning-of-item)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
344 (when (and (> (+ c-on c-off) 0)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
345 (re-search-forward re-box (point-at-eol) t))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
346 (setq beg-cookie (match-beginning 2)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
347 end-cookie (match-end 2))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
348 (delete-region beg-cookie end-cookie)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
349 (goto-char beg-cookie)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
350 (cond ((= c-off 0) (insert "[X]"))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
351 ((= c-on 0) (insert "[ ]"))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
352 (t (insert "[-]")))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
353 )))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
354 (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
355 (when (interactive-p)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
356 (message "Checkbox statistics updated %s (%d places)"
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
357 (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
358
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
359 (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
360 "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
361 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
362 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
363 (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
364 (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
365 (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
366 (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
367 'org-done
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
368 'org-todo)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
369
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
370 (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
371 "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
372 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
373 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
374 (let ((pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
375 (limit (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
376 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 (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
379 (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
380 (error (point-min)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 (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
382 ind ind1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383 (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
384 (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
385 (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
386 (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
387 (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
388 (if (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390 (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
391 (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
392
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393 (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
394 (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
395 (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
396 (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
397 (if (< ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
398 (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
399 nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401 (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
402
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403 (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
404 "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
405 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
406 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407 (let* ((pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 ind1
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409 (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
410 (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
411 (ind (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
412 (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
413 (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
414 (current-column)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
415 (end (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
416 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
417 (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
418 (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
419 (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
420 (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
421 (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
422 (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
423 (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
424 (if (<= ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
425 (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
426 (if end
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427 (goto-char end)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 (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
430
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
431 (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
432 "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
433 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
434 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
435 (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
436 (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
437 (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
438 (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
439 (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
440 (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
441 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442 (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
443
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
444 (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
445 "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
446 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
447 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 (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
449 (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
450 (setq beg (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
451 (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
452 (goto-char beg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
454 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
455 (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
456 (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
457 nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
458 (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
459 (throw 'exit t)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
460 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
461 (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
462 (< ind1 (1- ind)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
463 (error "")
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 (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
466 (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
467
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
468 (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
469 "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
470 (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
471 (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
472 (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
473 (= (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
474
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
475 (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
476 "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
477 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
478 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
479 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480 (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
481 (pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482 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
483 (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
484 (setq beg0 (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 (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
487 (setq beg (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
488 (goto-char beg0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
489 (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
490 (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
491 (setq end0 (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
492 (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
493 (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
494 (setq end (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
495 (goto-char beg0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
496 (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
497 ;; include less whitespace
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
498 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
499 (goto-char beg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
500 (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
501 (setq beg (point))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
502 (goto-char end0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503 (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
504 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
505 (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
506 (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
507 (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
508 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
509 (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
510 (setq pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 (insert txt)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 (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
513 (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
514 (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
515 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 (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
517 (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
518
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
519 (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
520 "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
521 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
522 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
523 (interactive "p")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 (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
525 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
526 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
527 (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
528 (setq beg0 (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 (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
530 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 (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
532 (setq beg (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 (goto-char beg0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 (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
535 (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
536 (setq end (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537 (goto-char beg0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 (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
541 (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
542 (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
543 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544 (goto-char pos)
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 nil)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547 (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
548 (throw 'exit t)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550 (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
551 (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
552 (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
553 (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
554 (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
555 (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
556 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 (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
558 (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
559 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 (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
561 (setq pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 (insert txt)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 (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
564 (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
565
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 (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
567 ;; 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
568 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 (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
570 (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
571 (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
572 (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
573
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 (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
575 (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
576 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 (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
578 (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
579
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
580 (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
581 "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
582 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
583 doing the renumbering."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585 (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
586 (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
587 (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
588 (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
589 (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
590
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591 (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
592 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 (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
595 (error nil)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597 (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
598 "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
599 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
600
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
601 `-' -> `+' -> `*' -> `1.' -> `1)'
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 If WHICH is a string, use that as the new bullet. If WHICH is an integer,
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
604 0 means `-', 1 means `+' etc."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 (interactive "P")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606 (org-preserve-lc
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607 (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
608 (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
609 (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
610 (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
611 (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
612 new old)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613 (setq new (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614 ((and (numberp which)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 (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
616 ((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
617 ((string-match "\\+" current)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 (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
619 ((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
620 ((string-match "\\." current)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
621 (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
622 ((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
623 (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
624 (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
625 (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
626 (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
627 (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
628 (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
629 (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
630
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
631 (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
632 "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
633 (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
634 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
635 (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
636 (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
637 (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
638 ((= 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
639 (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
640 i))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
641
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
642 (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
643 "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
644 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
645 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
646 (interactive "p")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
647 (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
648 (match-beginning 3))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
649 (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
650 (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
651 (col (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
652 (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
653 (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
654 ;; (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
655 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
656 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
657 ;; 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
658 (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
659 (setq bobp (bobp))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
660 (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
661 (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
662 (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
663 ;; 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
664 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
665 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 (catch 'next
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 (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
668 (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
669 (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
670 (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
671 (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
672 (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
673 (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
674 (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
675 (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
676 (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
677 (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
678 (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
679 (goto-line line)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
680 (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
681
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
682 (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
683 "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
684 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
685 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
686 (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
687 (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
688 (col (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
689 (ind (current-indentation))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
690 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
691 ;; 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
692 (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
693 (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
694 ;; 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
695 (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
696 (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
697 (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
698 (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
699 (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
700 ;; 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
701 (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
702 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
703 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
704 (catch 'next
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
705 (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
706 (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
707 (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
708 (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
709 (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
710 (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
711 (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
712 (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
713 (looking-at "\\S-+ *")
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
714 (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
715 (replace-match bullet)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
716 (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
717 (goto-line line)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
718 (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
719 (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
720 (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
721
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
722 (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
723 "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
724 (save-excursion
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
725 (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
726 (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
727 i)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
728 (goto-char end)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
729 (beginning-of-line 0)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
730 (while (> (point) beg)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
731 (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
732 ;; 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
733 (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
734 (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
735 (indent-line-to i)))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
736 (beginning-of-line 0)))))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
737
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
738 (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
739 "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
740 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
741 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742 (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
743 (let ((pos (point-at-bol))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
744 (ind (org-get-indentation))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 ind1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746 ;; 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
747 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
748 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749 (catch 'next
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
750 (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
751 (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
752 (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
753 (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
754 (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
755 (and (= ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756 (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
757 (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
758 (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
759 (throw 'exit t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
760 (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
761 (goto-char pos)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
762
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
764 (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
765 "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
766 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
767 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
768 (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
769 (let ((pos (point-at-bol))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
770 (ind (org-get-indentation))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 ind1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
772 ;; 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
773 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
775 (catch 'next
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776 (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
777 (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
778 (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
779 (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
780 (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
781 (and (= ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
782 (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
783 (eobp))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
784 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
785 (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
786 (throw 'exit t))))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
787 (goto-char pos)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
788
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 (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
791 (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
792
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
793 (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
794 "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
795 (interactive "p")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
796 (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
797
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 (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
799 "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
800 (interactive "p")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
801 (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
802 (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
803 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
804 (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
805 (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
806 (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
807 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
808 (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
809 (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
810 (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
811 (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
812 (goto-char beg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
813 (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
814 ind (car tmp)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
815 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
816 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
817 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
818 (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
819 (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
820 (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
821 (while (< (point) end)
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 1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
823 (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
824 (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
825 (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
826 (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
827 (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
828 (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
829 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
830 (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
831 (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
832 (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
833
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
834 (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
835 "Return indentation for plain list items.
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
836 This returns a list with three values: The current indentation, the
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
837 parent indentation and the indentation a child should have.
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
838 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
839 (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
840 (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
841 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
842 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
843 (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
844 (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
845 (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
846 (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
847 (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
848 (setq pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
849 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
850 (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851 ((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
852 (error nil))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
853 (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
854 (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
855 (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
856 ((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
857 (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
858 (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
859 (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
860 (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
861 (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
862
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
863
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
864 ;;; 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
865
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
866 (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
867 "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
868 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
869 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
870 (let* ((item-beginning (org-list-item-beginning))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
871 (start (car item-beginning))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
872 (end (org-list-end (cdr item-beginning)))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
873 output itemsep ltype)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
874 (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
875 (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
876 (save-match-data
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
877 (cond ((string-match "[0-9]" (match-string 2))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
878 (setq itemsep "[0-9]+\\(?:\\.\\|)\\)"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
879 ltype 'ordered))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
880 ((string-match "^.*::" (match-string 0))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
881 (setq itemsep "[-+]" ltype 'descriptive))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
882 (t (setq itemsep "[-+]" ltype 'unordered))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
883 (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
884 (nextitem (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
885 (save-match-data
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
886 (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
887 (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
888 (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
889 (item (buffer-substring
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
890 (point)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
891 (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
892 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
893 (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
894 (goto-char end))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
895 (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
896 (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
897 (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
898 (replace-match "\\\\texttt{\\&}"
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
899 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
900 (push item output)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
901 (when (> (length nextindent)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
902 (length indent1))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
903 (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
904 (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
905 (widen))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
906 (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
907 (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
908 (push ltype output)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
909
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
910 (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
911 "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
912 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
913 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
914 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
915 (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
916 (re-search-backward
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
917 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
918 (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
919 (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
920
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
921 (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
922 "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
923 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
924 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
925 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926 (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
927 (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
928 (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
929 (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
930 (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
931
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
932 (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
933 "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
934 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
935 (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
936 (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
937 name pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
938 (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
939 (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
940 (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
941 (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
942 (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
943 (setq pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
944 (insert txt)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
945 (goto-char pos)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
946
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
947 (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
948 "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
949 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
950 this list."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
951 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
952 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
953 (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
954 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
955 (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
956 (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
957 (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
958 (if maybe
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
959 (throw 'exit nil)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
960 (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
961 (let* ((name (match-string 1))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
962 (item-beginning (org-list-item-beginning))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
963 (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
964 (txt (buffer-substring-no-properties
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
965 (car item-beginning)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
966 (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
967 (list (org-list-parse-list))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
968 beg)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
969 (unless (fboundp transform)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
970 (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
971 (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
972 ;; 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
973 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974 (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
975 (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
976 (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
977 (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
978 (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
979 (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
980 (setq beg (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981 (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
982 (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
983 (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
984 (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
985 (goto-char beg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
986 (insert txt "\n"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
987 (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
988
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
989 (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
990 "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
991
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
992 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
993
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
994 :ustart String to start an unordered list
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
995 :uend String to end an unordered list
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
996
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
997 :ostart String to start an ordered list
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
998 :oend String to end an ordered list
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
999
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1000 :dstart String to start a descriptive list
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1001 :dend String to end a descriptive list
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1002 :dtstart String to start a descriptive term
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1003 :dtend String to end a descriptive term
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1004 :ddstart String to start a description
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1005 :ddend String to end a description
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1007 :splice When set to t, return only list body lines, don't wrap
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1008 them into :[u/o]start and :[u/o]end. Default is nil.
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1009
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1010 :istart String to start a list item
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1011 :iend String to end a list item
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1012 :isep String to separate items
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1013 :lsep String to separate sublists"
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1014 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1015 (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
1016 (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
1017 (ostart (plist-get p :ostart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1018 (oend (plist-get p :oend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1019 (ustart (plist-get p :ustart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1020 (uend (plist-get p :uend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1021 (dstart (plist-get p :dstart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1022 (dend (plist-get p :dend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1023 (dtstart (plist-get p :dtstart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1024 (dtend (plist-get p :dtend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1025 (ddstart (plist-get p :ddstart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1026 (ddend (plist-get p :ddend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1027 (istart (plist-get p :istart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1028 (iend (plist-get p :iend))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1029 (isep (plist-get p :isep))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1030 (lsep (plist-get p :lsep)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1031 (let ((wrapper
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1032 (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
1033 (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
1034 ((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
1035 (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
1036 ((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
1037 (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
1038 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
1039 (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
1040 (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
1041 ((stringp sublist)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1042 (when (string-match "^\\(.*\\) ::" sublist)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1043 (setq term (org-trim (format (concat dtstart "%s" dtend)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1044 (match-string 1 sublist))))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1045 (setq sublist (substring sublist (1+ (length term)))))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1046 (setq rtn (concat rtn istart term ddstart
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1047 sublist ddend iend isep)))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1048 (t (setq rtn (concat rtn ;; previous list
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1049 lsep ;; list separator
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1050 (org-list-to-generic sublist p)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1051 lsep ;; list separator
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1052 )))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1053 (format wrapper rtn))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1054
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1055 (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
1056 "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
1057 (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
1058 list '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1059 :ustart "\\begin{itemize}" :uend "\\end{itemize}"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1060 :dstart "\\begin{description}" :dend "\\end{description}"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1061 :dtstart "[" :dtend "]"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1062 :ddstart "" :ddend ""
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1063 :istart "\\item " :iend ""
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1064 :isep "\n" :lsep "\n")))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1065
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1066 (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
1067 "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
1068 (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
1069 list '(:splicep nil :ostart "<ol>" :oend "</ol>"
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1070 :ustart "<ul>" :uend "</ul>"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1071 :dstart "<dl>" :dend "</dl>"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1072 :dtstart "<dt>" :dtend "</dt>"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1073 :ddstart "<dd>" :ddend "</dd>"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1074 :istart "<li>" :iend "</li>"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1075 :isep "\n" :lsep "\n")))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1076
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1077 (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
1078 "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
1079 (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
1080 list '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1081 :ustart "@enumerate" :uend "@end enumerate"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1082 :dstart "@table" :dend "@end table"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1083 :dtstart "@item " :dtend "\n"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1084 :ddstart "" :ddend ""
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1085 :istart "@item\n" :iend ""
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1086 :isep "\n" :lsep "\n")))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1087
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1088 (provide 'org-list)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1089
98696
7e941d6d7c4c Add arch tagline
Miles Bader <miles@gnu.org>
parents: 98645
diff changeset
1090 ;; 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
1091 ;;; org-list.el ends here