Mercurial > emacs
annotate lisp/org/org-list.el @ 111506:5cb272c831e8
Install org-mode version 7.3
author | Carsten Dominik <carsten.dominik@gmail.com> |
---|---|
date | Thu, 11 Nov 2010 22:10:19 -0600 |
parents | 063e94b66261 |
children | a7740098b594 |
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 ;; |
106815 | 3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
101515
64ef70f990a9
2009-01-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
101458
diff
changeset
|
4 ;; 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
|
5 ;; |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
6 ;; 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
|
7 ;; 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
|
8 ;; 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
|
9 ;; Homepage: http://orgmode.org |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
10 ;; Version: 7.3 |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
11 ;; |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
12 ;; 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
|
13 ;; |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
14 ;; 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
|
15 ;; 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
|
16 ;; 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
|
17 ;; (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
|
18 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 ;; 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
|
23 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
24 ;; 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
|
25 ;; 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
|
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
27 ;; |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
28 ;;; Commentary: |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
29 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
30 ;; 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
|
31 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
32 ;;; Code: |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
33 |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
34 (eval-when-compile |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
35 (require 'cl)) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
36 (require 'org-macs) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
37 (require 'org-compat) |
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 (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
|
40 (defvar org-M-RET-may-split-line) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
41 (defvar org-complex-heading-regexp) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
42 (defvar org-odd-levels-only) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
43 (defvar org-outline-regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
44 (defvar org-ts-regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
45 (defvar org-ts-regexp-both) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
46 |
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-invisible-p "org" ()) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
48 (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
|
49 (declare-function outline-next-heading "outline" ()) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
50 (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
|
51 (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
|
52 (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
|
53 (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
|
54 (declare-function org-timer-item "org-timer" (&optional arg)) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
55 (declare-function org-timer-hms-to-secs "org-timer" (hms)) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
56 (declare-function org-combine-plists "org" (&rest plists)) |
109812
063e94b66261
Fix some Org errors revealed by `make check-declare'.
Glenn Morris <rgm@gnu.org>
parents:
109462
diff
changeset
|
57 (declare-function org-entry-get "org" |
063e94b66261
Fix some Org errors revealed by `make check-declare'.
Glenn Morris <rgm@gnu.org>
parents:
109462
diff
changeset
|
58 (pom property &optional inherit literal-nil)) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
59 (declare-function org-narrow-to-subtree "org" ()) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
60 (declare-function org-show-subtree "org" ()) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
61 (declare-function org-in-regexps-block-p "org" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
62 (start-re end-re &optional bound)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
63 (declare-function org-level-increment "org" ()) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
64 (declare-function org-at-heading-p "org" (&optional ignored)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
65 (declare-function outline-previous-heading "outline" ()) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
66 (declare-function org-icompleting-read "org" (&rest args)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
67 (declare-function org-time-string-to-seconds "org" (s)) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
68 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
69 (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
|
70 "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
|
71 :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
|
72 :group 'org-structure) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
73 |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
74 (defcustom org-cycle-include-plain-lists t |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
75 "When t, make TAB cycle visibility on plain list items. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
76 Cycling plain lists works only when the cursor is on a plain list |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
77 item. When the cursor is on an outline heading, plain lists are |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
78 treated as text. This is the most stable way of handling this, |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
79 which is why it is the default. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
80 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
81 When this is the symbol `integrate', then during cycling, plain |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
82 list items will *temporarily* be interpreted as outline headlines |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
83 with a level given by 1000+i where i is the indentation of the |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
84 bullet. This setting can lead to strange effects when switching |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
85 visibility to `children', because the first \"child\" in a |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
86 subtree decides what children should be listed. If that first |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
87 \"child\" is a plain list item with an implied large level |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
88 number, all true children and grand children of the outline |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
89 heading will be exposed in a children' view." |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
90 :group 'org-plain-lists |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
91 :type '(choice |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
92 (const :tag "Never" nil) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
93 (const :tag "With cursor in plain list (recommended)" t) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
94 (const :tag "As children of outline headings" integrate))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
95 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
96 (defcustom org-list-demote-modify-bullet nil |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
97 "Default bullet type installed when demoting an item. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
98 This is an association list, for each bullet type, this alist will point |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
99 to the bullet that should be used when this item is demoted. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
100 For example, |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
101 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
102 (setq org-list-demote-modify-bullet |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
103 '((\"+\" . \"-\") (\"-\" . \"+\") (\"*\" . \"+\"))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
104 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
105 will make |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
106 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
107 + Movies |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
108 + Silence of the Lambs |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
109 + My Cousin Vinny |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
110 + Books |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
111 + The Hunt for Red October |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
112 + The Road to Omaha |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
113 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
114 into |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
115 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
116 + Movies |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
117 - Silence of the Lambs |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
118 - My Cousin Vinny |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
119 + Books |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
120 - The Hunt for Red October |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
121 - The Road to Omaha" |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
122 :group 'org-plain-lists |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
123 :type '(repeat |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
124 (cons |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
125 (choice :tag "If the current bullet is " |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
126 (const "-") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
127 (const "+") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
128 (const "*") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
129 (const "1.") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
130 (const "1)")) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
131 (choice :tag "demotion will change it to" |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
132 (const "-") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
133 (const "+") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
134 (const "*") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
135 (const "1.") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
136 (const "1)"))))) |
98645
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 (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
|
139 "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
|
140 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
|
141 ?. 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
|
142 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
|
143 the safe choice." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
144 :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
|
145 :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
|
146 (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
|
147 (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
|
148 |
99849
621e15919df0
2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99501
diff
changeset
|
149 (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
|
150 "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
|
151 When nil, no bullet will have two spaces after them. |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
152 When a string, it will be used as a regular expression. When the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
153 bullet type of a list is changed, the new bullet type will be |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
154 matched against this regexp. If it matches, there will be two |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
155 spaces instead of one after the bullet in each item of the list." |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
156 :group 'org-plain-lists |
99849
621e15919df0
2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99501
diff
changeset
|
157 :type '(choice |
621e15919df0
2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99501
diff
changeset
|
158 (const :tag "never" nil) |
621e15919df0
2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99501
diff
changeset
|
159 (regexp))) |
621e15919df0
2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99501
diff
changeset
|
160 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
161 (defcustom org-list-ending-method 'both |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
162 "Determine where plain lists should end. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
163 Valid values are: `regexp', `indent' or `both'. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
164 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
165 When set to `regexp', Org will look into two variables, |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
166 `org-empty-line-terminates-plain-lists' and the more general |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
167 `org-list-end-regexp', to determine what will end lists. This is |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
168 the fastest method. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
169 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
170 When set to `indent', a list will end whenever a line following |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
171 an item, but not starting one, is less or equally indented than |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
172 it. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
173 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
174 When set to `both', each of the preceding methods is applied to |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
175 determine lists endings. This is the default method." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
176 :group 'org-plain-lists |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
177 :type '(choice |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
178 (const :tag "With a regexp defining ending" regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
179 (const :tag "With indentation of regular (no bullet) text" indent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
180 (const :tag "With both methods" both))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
181 |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
182 (defcustom org-empty-line-terminates-plain-lists nil |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
183 "Non-nil means an empty line ends all plain list levels. |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
184 This variable only makes sense if `org-list-ending-method' is set |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
185 to `regexp' or `both'. This is then equivalent to set |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
186 `org-list-end-regexp' to \"^[ \\t]*$\"." |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
187 :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
|
188 :type 'boolean) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
189 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
190 (defcustom org-list-end-regexp "^[ \t]*\n[ \t]*\n" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
191 "Regexp matching the end of all plain list levels. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
192 It must start with \"^\" and end with \"\\n\". It defaults to 2 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
193 blank lines. `org-empty-line-terminates-plain-lists' has |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
194 precedence over it." |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
195 :group 'org-plain-lists |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
196 :type 'string) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
197 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
198 (defcustom org-list-automatic-rules '((bullet . t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
199 (checkbox . t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
200 (indent . t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
201 (insert . t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
202 "Non-nil means apply set of rules when acting on lists. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
203 By default, automatic actions are taken when using |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
204 \\[org-meta-return], \\[org-metaright], \\[org-metaleft], |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
205 \\[org-shiftmetaright], \\[org-shiftmetaleft], |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
206 \\[org-ctrl-c-minus], \\[org-toggle-checkbox] or |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
207 \\[org-insert-todo-heading]. You can disable individually these |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
208 rules by setting them to nil. Valid rules are: |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
209 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
210 bullet when non-nil, cycling bullet do not allow lists at |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
211 column 0 to have * as a bullet and descriptions lists |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
212 to be numbered. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
213 checkbox when non-nil, checkbox statistics is updated each time |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
214 you either insert a new checkbox or toggle a checkbox. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
215 It also prevents from inserting a checkbox in a |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
216 description item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
217 indent when non-nil, indenting or outdenting list top-item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
218 with its subtree will move the whole list and |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
219 outdenting a list whose bullet is * to column 0 will |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
220 change that bullet to - |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
221 insert when non-nil, trying to insert an item inside a block |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
222 will insert it right before the block instead of |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
223 throwing an error." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
224 :group 'org-plain-lists |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
225 :type '(alist :tag "Sets of rules" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
226 :key-type |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
227 (choice |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
228 (const :tag "Bullet" bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
229 (const :tag "Checkbox" checkbox) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
230 (const :tag "Indent" indent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
231 (const :tag "Insert" insert)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
232 :value-type |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
233 (boolean :tag "Activate" :value t))) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
234 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
235 (defcustom org-hierarchical-checkbox-statistics t |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
236 "Non-nil means checkbox statistics counts only the state of direct children. |
104810
86b7fe7d1d8f
2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
104164
diff
changeset
|
237 When nil, all boxes below the cookie are counted. |
105973
b7d8222914b4
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
105341
diff
changeset
|
238 This can be set to nil on a per-node basis using a COOKIE_DATA property |
104810
86b7fe7d1d8f
2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
104164
diff
changeset
|
239 with the word \"recursive\" in the value." |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
240 :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
|
241 :type 'boolean) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
242 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
243 (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
|
244 "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
|
245 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
|
246 5 characters instead." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
247 :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
|
248 :type 'integer) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
249 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
250 (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
|
251 '((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
|
252 % 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
|
253 \\begin{comment} |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
254 #+ORGLST: SEND %n org-list-to-latex |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
255 - |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
256 \\end{comment}\n") |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
257 (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
|
258 @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
|
259 @ignore |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
260 #+ORGLST: SEND %n org-list-to-texinfo |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
261 - |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
262 @end ignore\n") |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
263 (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
|
264 <!-- 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
|
265 <!-- |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
266 #+ORGLST: SEND %n org-list-to-html |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
267 - |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
268 -->\n")) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
269 "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
|
270 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
|
271 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
|
272 :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
|
273 :type '(repeat |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
274 (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
|
275 (string :tag "Format")))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
276 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
277 ;;; Internal functions |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
278 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
279 (defun org-list-end-re () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
280 "Return the regex corresponding to the end of a list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
281 It depends on `org-empty-line-terminates-plain-lists'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
282 (if org-empty-line-terminates-plain-lists |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
283 "^[ \t]*\n" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
284 org-list-end-regexp)) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
285 |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
286 (defun org-item-re (&optional general) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
287 "Return the correct regular expression for plain lists. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
288 If GENERAL is non-nil, return the general regexp independent of the value |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
289 of `org-plain-list-ordered-item-terminator'." |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
290 (cond |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
291 ((or general (eq org-plain-list-ordered-item-terminator t)) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
292 "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)") |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
293 ((= org-plain-list-ordered-item-terminator ?.) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
294 "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)") |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
295 ((= org-plain-list-ordered-item-terminator ?\)) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
296 "\\([ \t]*\\([-+]\\|\\([0-9]+)\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)") |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
297 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
298 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
299 (defconst org-item-beginning-re (concat "^" (org-item-re)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
300 "Regexp matching the beginning of a plain list item.") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
301 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
302 (defun org-list-ending-between (min max &optional firstp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
303 "Find the position of a list ending between MIN and MAX, or nil. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
304 This function looks for `org-list-end-re' outside a block. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
305 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
306 If FIRSTP in non-nil, return the point at the beginning of the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
307 nearest valid terminator from MIN. Otherwise, return the point at |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
308 the end of the nearest terminator from MAX." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
309 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
310 (let* ((start (if firstp min max)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
311 (end (if firstp max min)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
312 (search-fun (if firstp |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
313 #'org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
314 #'org-search-backward-unenclosed)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
315 (list-end-p (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
316 (goto-char start) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
317 (funcall search-fun (org-list-end-re) end t)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
318 ;; Is there a valid list ending somewhere ? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
319 (and list-end-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
320 ;; we want to be on the first line of the list ender |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
321 (match-beginning 0))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
322 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
323 (defun org-list-maybe-skip-block (search limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
324 "Return non-nil value if point is in a block, skipping it on the way. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
325 It looks for the boundary of the block in SEARCH direction, |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
326 stopping at LIMIT." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
327 (save-match-data |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
328 (let ((case-fold-search t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
329 (boundary (if (eq search 're-search-forward) 3 5))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
330 (when (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
331 (and (funcall search "^[ \t]*#\\+\\(begin\\|end\\)_" limit t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
332 (= (length (match-string 1)) boundary))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
333 ;; We're in a block: get out of it |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
334 (goto-char (match-beginning 0)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
335 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
336 (defun org-list-search-unenclosed-generic (search re bound noerr) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
337 "Search a string outside blocks and protected places. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
338 Arguments SEARCH, RE, BOUND and NOERR are similar to those in |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
339 `search-forward', `search-backward', `re-search-forward' and |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
340 `re-search-backward'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
341 (catch 'exit |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
342 (let ((origin (point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
343 (while t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
344 ;; 1. No match: return to origin or bound, depending on NOERR. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
345 (unless (funcall search re bound noerr) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
346 (throw 'exit (and (goto-char (if (memq noerr '(t nil)) origin bound)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
347 nil))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
348 ;; 2. Match not in block or protected: return point. Else |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
349 ;; skip the block and carry on. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
350 (unless (or (get-text-property (match-beginning 0) 'org-protected) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
351 (org-list-maybe-skip-block search bound)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
352 (throw 'exit (point))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
353 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
354 (defun org-search-backward-unenclosed (regexp &optional bound noerror) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
355 "Like `re-search-backward' but don't stop inside blocks or protected places. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
356 Arguments REGEXP, BOUND and NOERROR are similar to those used in |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
357 `re-search-backward'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
358 (org-list-search-unenclosed-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
359 #'re-search-backward regexp (or bound (point-min)) noerror)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
360 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
361 (defun org-search-forward-unenclosed (regexp &optional bound noerror) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
362 "Like `re-search-forward' but don't stop inside blocks or protected places. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
363 Arguments REGEXP, BOUND and NOERROR are similar to those used in |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
364 `re-search-forward'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
365 (org-list-search-unenclosed-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
366 #'re-search-forward regexp (or bound (point-max)) noerror)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
367 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
368 (defun org-list-in-item-p-with-indent (limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
369 "Is the cursor inside a plain list? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
370 Plain lists are considered ending when a non-blank line is less |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
371 indented than the previous item within LIMIT." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
372 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
373 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
374 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
375 ;; do not start searching inside a block... |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
376 ((org-list-maybe-skip-block #'re-search-backward limit)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
377 ;; ... or at a blank line |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
378 ((looking-at "^[ \t]*$") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
379 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
380 (beginning-of-line))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
381 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
382 (or (org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
383 (let* ((case-fold-search t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
384 (ind-ref (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
385 ;; Ensure there is at least an item above |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
386 (up-item-p (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
387 (org-search-backward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
388 org-item-beginning-re limit t)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
389 (and up-item-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
390 (catch 'exit |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
391 (while t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
392 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
393 ((org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
394 (throw 'exit (< (org-get-indentation) ind-ref))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
395 ((looking-at "^[ \t]*$") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
396 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
397 (beginning-of-line)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
398 ((looking-at "^[ \t]*#\\+end_") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
399 (re-search-backward "^[ \t]*#\\+begin_")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
400 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
401 (setq ind-ref (min (org-get-indentation) ind-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
402 (forward-line -1)))))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
403 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
404 (defun org-list-in-item-p-with-regexp (limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
405 "Is the cursor inside a plain list? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
406 Plain lists end when `org-list-end-regexp' is matched, or at a |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
407 blank line if `org-empty-line-terminates-plain-lists' is true. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
408 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
409 Argument LIMIT specifies the upper-bound of the search." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
410 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
411 (let* ((actual-pos (goto-char (point-at-eol))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
412 ;; Moved to eol so current line can be matched by |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
413 ;; `org-item-re'. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
414 (last-item-start (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
415 (org-search-backward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
416 org-item-beginning-re limit t))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
417 (list-ender (org-list-ending-between |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
418 last-item-start actual-pos))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
419 ;; We are in a list when we are on an item line or when we can |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
420 ;; find an item before point and there is no valid list ender |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
421 ;; between it and the point. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
422 (and last-item-start (not list-ender))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
423 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
424 (defun org-list-top-point-with-regexp (limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
425 "Return point at the top level item in a list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
426 Argument LIMIT specifies the upper-bound of the search. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
427 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
428 List ending is determined by regexp. See |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
429 `org-list-ending-method'. for more information." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
430 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
431 (let ((pos (point-at-eol))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
432 ;; Is there some list above this one ? If so, go to its ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
433 ;; Otherwise, go back to the heading above or bob. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
434 (goto-char (or (org-list-ending-between limit pos) limit)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
435 ;; From there, search down our list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
436 (org-search-forward-unenclosed org-item-beginning-re pos t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
437 (point-at-bol)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
438 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
439 (defun org-list-bottom-point-with-regexp (limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
440 "Return point just before list ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
441 Argument LIMIT specifies the lower-bound of the search. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
442 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
443 List ending is determined by regexp. See |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
444 `org-list-ending-method'. for more information." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
445 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
446 (let ((pos (org-get-item-beginning))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
447 ;; The list ending is either first point matching |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
448 ;; `org-list-end-re', point at first white-line before next |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
449 ;; heading, or eob. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
450 (or (org-list-ending-between (min pos limit) limit t) limit)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
451 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
452 (defun org-list-top-point-with-indent (limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
453 "Return point at the top level in a list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
454 Argument LIMIT specifies the upper-bound of the search. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
455 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
456 List ending is determined by indentation of text. See |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
457 `org-list-ending-method'. for more information." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
458 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
459 (let ((case-fold-search t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
460 (let ((item-ref (goto-char (org-get-item-beginning))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
461 (ind-ref 10000)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
462 (forward-line -1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
463 (catch 'exit |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
464 (while t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
465 (let ((ind (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
466 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
467 ((looking-at "^[ \t]*:END:") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
468 (throw 'exit item-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
469 ((<= (point) limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
470 (throw 'exit |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
471 (if (and (org-at-item-p) (< ind ind-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
472 (point-at-bol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
473 item-ref))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
474 ((looking-at "^[ \t]*$") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
475 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
476 (beginning-of-line)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
477 ((looking-at "^[ \t]*#\\+end_") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
478 (re-search-backward "^[ \t]*#\\+begin_")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
479 ((not (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
480 (setq ind-ref (min ind ind-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
481 (forward-line -1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
482 ((>= ind ind-ref) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
483 (throw 'exit item-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
484 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
485 (setq item-ref (point-at-bol) ind-ref 10000) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
486 (forward-line -1)))))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
487 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
488 (defun org-list-bottom-point-with-indent (limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
489 "Return point just before list ending or nil if not in a list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
490 Argument LIMIT specifies the lower-bound of the search. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
491 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
492 List ending is determined by the indentation of text. See |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
493 `org-list-ending-method' for more information." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
494 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
495 (let ((ind-ref (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
496 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
497 (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
498 (case-fold-search t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
499 ;; do not start inside a block |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
500 (org-list-maybe-skip-block #'re-search-forward limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
501 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
502 (catch 'exit |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
503 (while t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
504 (skip-chars-forward " \t") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
505 (let ((ind (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
506 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
507 ((or (>= (point) limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
508 (looking-at ":END:")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
509 (throw 'exit (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
510 ;; Ensure bottom is just after a |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
511 ;; non-blank line. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
512 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
513 (min (point-max) (1+ (point-at-eol)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
514 ((= (point) (point-at-eol)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
515 (skip-chars-forward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
516 (beginning-of-line)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
517 ((org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
518 (setq ind-ref ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
519 (forward-line 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
520 ((<= ind ind-ref) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
521 (throw 'exit (point-at-bol))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
522 ((looking-at "#\\+begin_") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
523 (re-search-forward "[ \t]*#\\+end_") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
524 (forward-line 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
525 (t (forward-line 1))))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
526 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
527 (defun org-list-at-regexp-after-bullet-p (regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
528 "Is point at a list item with REGEXP after bullet?" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
529 (and (org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
530 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
531 (goto-char (match-end 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
532 ;; Ignore counter if any |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
533 (when (looking-at "\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
534 (goto-char (match-end 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
535 (looking-at regexp)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
536 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
537 (defun org-list-get-item-same-level (search-fun pos limit pre-move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
538 "Return point at the beginning of next item at the same level. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
539 Search items using function SEARCH-FUN, from POS to LIMIT. It |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
540 uses PRE-MOVE before search. Return nil if no item was found." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
541 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
542 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
543 (let* ((start (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
544 (ind (progn (goto-char start) (org-get-indentation)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
545 ;; We don't want to match the current line. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
546 (funcall pre-move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
547 ;; Skip any sublist on the way |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
548 (while (and (funcall search-fun org-item-beginning-re limit t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
549 (> (org-get-indentation) ind))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
550 (when (and (/= (point-at-bol) start) ; Have we moved ? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
551 (= (org-get-indentation) ind)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
552 (point-at-bol))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
553 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
554 (defun org-list-separating-blank-lines-number (pos top bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
555 "Return number of blank lines that should separate items in list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
556 POS is the position of point to be considered. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
557 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
558 TOP and BOTTOM are respectively position of list beginning and |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
559 list ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
560 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
561 Assume point is at item's beginning. If the item is alone, apply |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
562 some heuristics to guess the result." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
563 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
564 (let ((insert-blank-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
565 (cdr (assq 'plain-list-item org-blank-before-new-entry))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
566 usr-blank) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
567 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
568 ;; Trivial cases where there should be none. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
569 ((or (and (not (eq org-list-ending-method 'indent)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
570 org-empty-line-terminates-plain-lists) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
571 (not insert-blank-p)) 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
572 ;; When `org-blank-before-new-entry' says so, it is 1. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
573 ((eq insert-blank-p t) 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
574 ;; plain-list-item is 'auto. Count blank lines separating |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
575 ;; neighbours items in list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
576 (t (let ((next-p (org-get-next-item (point) bottom))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
577 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
578 ;; Is there a next item? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
579 (next-p (goto-char next-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
580 (org-back-over-empty-lines)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
581 ;; Is there a previous item? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
582 ((org-get-previous-item (point) top) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
583 (org-back-over-empty-lines)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
584 ;; User inserted blank lines, trust him |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
585 ((and (> pos (org-end-of-item-before-blank bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
586 (> (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
587 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
588 (skip-chars-backward " \t") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
589 (setq usr-blank (org-back-over-empty-lines))) 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
590 usr-blank) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
591 ;; Are there blank lines inside the item ? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
592 ((save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
593 (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
594 "^[ \t]*$" (org-end-of-item-before-blank bottom) t)) 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
595 ;; No parent: no blank line. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
596 (t 0)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
597 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
598 (defun org-list-insert-item-generic (pos &optional checkbox after-bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
599 "Insert a new list item at POS. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
600 If POS is before first character after bullet of the item, the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
601 new item will be created before the current one. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
602 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
603 Insert a checkbox if CHECKBOX is non-nil, and string AFTER-BULLET |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
604 after the bullet. Cursor will be after this text once the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
605 function ends." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
606 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
607 ;; Is point in a special block? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
608 (when (org-in-regexps-block-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
609 "^[ \t]*#\\+\\(begin\\|BEGIN\\)_\\([a-zA-Z0-9_]+\\)" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
610 '(concat "^[ \t]*#\\+\\(end\\|END\\)_" (match-string 2))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
611 (if (not (cdr (assq 'insert org-list-automatic-rules))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
612 ;; Rule in `org-list-automatic-rules' forbids insertion. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
613 (error "Cannot insert item inside a block") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
614 ;; Else, move before it prior to add a new item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
615 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
616 (re-search-backward "^[ \t]*#\\+\\(begin\\|BEGIN\\)_" nil t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
617 (end-of-line 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
618 (let* ((true-pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
619 (top (org-list-top-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
620 (bottom (copy-marker (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
621 (bullet (and (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
622 (org-list-bullet-string (org-get-bullet)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
623 (ind (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
624 (before-p (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
625 ;; Description item: text starts after colons. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
626 (or (org-at-item-description-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
627 ;; At a checkbox: text starts after it. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
628 (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
629 ;; Otherwise, text starts after bullet. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
630 (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
631 (<= true-pos (match-end 0)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
632 (blank-lines-nb (org-list-separating-blank-lines-number |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
633 true-pos top bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
634 (insert-fun |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
635 (lambda (text) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
636 ;; insert bullet above item in order to avoid bothering |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
637 ;; with possible blank lines ending last item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
638 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
639 (indent-to-column ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
640 (insert (concat bullet (when checkbox "[ ] ") after-bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
641 ;; Stay between after-bullet and before text. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
642 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
643 (insert (concat text (make-string (1+ blank-lines-nb) ?\n)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
644 (unless before-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
645 ;; store bottom: exchanging items doesn't change list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
646 ;; bottom point but will modify marker anyway |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
647 (setq bottom (marker-position bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
648 (let ((col (current-column))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
649 (org-list-exchange-items |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
650 (org-get-item-beginning) (org-get-next-item (point) bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
651 bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
652 ;; recompute next-item: last sexp modified list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
653 (goto-char (org-get-next-item (point) bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
654 (org-move-to-column col))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
655 ;; checkbox update might modify bottom point, so use a |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
656 ;; marker here |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
657 (setq bottom (copy-marker bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
658 (when checkbox (org-update-checkbox-count-maybe)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
659 (org-list-repair nil top bottom)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
660 (goto-char true-pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
661 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
662 (before-p (funcall insert-fun nil) t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
663 ;; Can't split item: insert bullet at the end of item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
664 ((not (org-get-alist-option org-M-RET-may-split-line 'item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
665 (funcall insert-fun nil) t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
666 ;; else, insert a new bullet along with everything from point |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
667 ;; down to last non-blank line of item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
668 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
669 (delete-horizontal-space) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
670 ;; Get pos again in case previous command modified line. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
671 (let* ((pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
672 (end-before-blank (org-end-of-item-before-blank bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
673 (after-text |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
674 (when (< pos end-before-blank) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
675 (prog1 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
676 (delete-and-extract-region pos end-before-blank) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
677 ;; delete any blank line at and before point. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
678 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
679 (while (looking-at "^[ \t]*$") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
680 (delete-region (point-at-bol) (1+ (point-at-eol))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
681 (beginning-of-line 0)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
682 (funcall insert-fun after-text) t))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
683 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
684 (defvar org-last-indent-begin-marker (make-marker)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
685 (defvar org-last-indent-end-marker (make-marker)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
686 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
687 (defun org-list-indent-item-generic (arg no-subtree top bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
688 "Indent a local list item including its children. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
689 When number ARG is a negative, item will be outdented, otherwise |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
690 it will be indented. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
691 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
692 If a region is active, all items inside will be moved. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
693 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
694 If NO-SUBTREE is non-nil, only indent the item itself, not its |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
695 children. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
696 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
697 TOP and BOTTOM are respectively position at item beginning and at |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
698 item ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
699 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
700 Return t if successful." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
701 (let* ((regionp (org-region-active-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
702 (rbeg (and regionp (region-beginning))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
703 (rend (and regionp (region-end)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
704 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
705 ((and regionp |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
706 (goto-char rbeg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
707 (not (org-search-forward-unenclosed org-item-beginning-re rend t))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
708 (error "No item in region")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
709 ((not (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
710 (error "Not on an item")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
711 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
712 ;; Are we going to move the whole list? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
713 (let* ((specialp (and (cdr (assq 'indent org-list-automatic-rules)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
714 (not no-subtree) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
715 (= top (point-at-bol))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
716 ;; Determine begin and end points of zone to indent. If moving |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
717 ;; more than one item, ensure we keep them on subsequent moves. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
718 (unless (and (memq last-command '(org-shiftmetaright org-shiftmetaleft)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
719 (memq this-command '(org-shiftmetaright org-shiftmetaleft))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
720 (if regionp |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
721 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
722 (set-marker org-last-indent-begin-marker rbeg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
723 (set-marker org-last-indent-end-marker rend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
724 (set-marker org-last-indent-begin-marker (point-at-bol)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
725 (set-marker org-last-indent-end-marker |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
726 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
727 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
728 (specialp bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
729 (no-subtree (org-end-of-item-or-at-child bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
730 (t (org-get-end-of-item bottom))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
731 ;; Get everything ready |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
732 (let* ((beg (marker-position org-last-indent-begin-marker)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
733 (end (marker-position org-last-indent-end-marker)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
734 (struct (org-list-struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
735 beg end top (if specialp end bottom) (< arg 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
736 (origins (org-list-struct-origins struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
737 (beg-item (assq beg struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
738 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
739 ;; Special case: moving top-item with indent rule |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
740 (specialp |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
741 (let* ((level-skip (org-level-increment)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
742 (offset (if (< arg 0) (- level-skip) level-skip)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
743 (top-ind (nth 1 beg-item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
744 (if (< (+ top-ind offset) 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
745 (error "Cannot outdent beyond margin") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
746 ;; Change bullet if necessary |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
747 (when (and (= (+ top-ind offset) 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
748 (string-match "*" (nth 2 beg-item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
749 (setcdr beg-item (list (nth 1 beg-item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
750 (org-list-bullet-string "-")))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
751 ;; Shift ancestor |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
752 (let ((anc (car struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
753 (setcdr anc (list (+ (nth 1 anc) offset) "" nil))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
754 (org-list-struct-fix-struct struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
755 (org-list-struct-apply-struct struct end)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
756 ;; Forbidden move |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
757 ((and (< arg 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
758 (or (and no-subtree |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
759 (not regionp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
760 (org-list-struct-get-child beg-item struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
761 (let ((last-item (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
762 (goto-char end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
763 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
764 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
765 (org-list-struct-assoc-at-point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
766 (org-list-struct-get-child last-item struct)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
767 (error "Cannot outdent an item without its children")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
768 ;; Normal shifting |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
769 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
770 (let* ((shifted-ori (if (< arg 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
771 (org-list-struct-outdent beg end origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
772 (org-list-struct-indent beg end origins struct)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
773 (org-list-struct-fix-struct struct shifted-ori) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
774 (org-list-struct-apply-struct struct bottom)))))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
775 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
776 ;;; Predicates |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
777 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
778 (defun org-in-item-p () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
779 "Is the cursor inside a plain list? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
780 This checks `org-list-ending-method'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
781 (unless (let ((outline-regexp org-outline-regexp)) (org-at-heading-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
782 (let* ((prev-head (save-excursion (outline-previous-heading))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
783 (bound (if prev-head |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
784 (or (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
785 (let ((case-fold-search t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
786 (re-search-backward "^[ \t]*:END:" prev-head t))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
787 prev-head) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
788 (point-min)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
789 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
790 ((eq org-list-ending-method 'regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
791 (org-list-in-item-p-with-regexp bound)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
792 ((eq org-list-ending-method 'indent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
793 (org-list-in-item-p-with-indent bound)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
794 (t (and (org-list-in-item-p-with-regexp bound) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
795 (org-list-in-item-p-with-indent bound))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
796 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
797 (defun org-list-first-item-p (top) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
798 "Is this item the first item in a plain list? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
799 Assume point is at an item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
800 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
801 TOP is the position of list's top-item." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
802 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
803 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
804 (let ((ind (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
805 (or (not (org-search-backward-unenclosed org-item-beginning-re top t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
806 (< (org-get-indentation) ind))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
807 |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
808 (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
|
809 "Is point in a line starting a hand-formatted item?" |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
810 (save-excursion |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
811 (beginning-of-line) (looking-at org-item-beginning-re))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
812 |
101568
f5aedb5cbd80
2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101515
diff
changeset
|
813 (defun org-at-item-bullet-p () |
f5aedb5cbd80
2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101515
diff
changeset
|
814 "Is point at the bullet of a plain list item?" |
f5aedb5cbd80
2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101515
diff
changeset
|
815 (and (org-at-item-p) |
f5aedb5cbd80
2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101515
diff
changeset
|
816 (not (member (char-after) '(?\ ?\t))) |
f5aedb5cbd80
2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101515
diff
changeset
|
817 (< (point) (match-end 0)))) |
f5aedb5cbd80
2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101515
diff
changeset
|
818 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
819 (defun org-at-item-timer-p () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
820 "Is point at a line starting a plain list item with a timer?" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
821 (org-list-at-regexp-after-bullet-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
822 "\\([0-9]+:[0-9]+:[0-9]+\\)[ \t]+::[ \t]+")) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
823 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
824 (defun org-at-item-description-p () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
825 "Is point at a description list item?" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
826 (org-list-at-regexp-after-bullet-p "\\(\\S-.+\\)[ \t]+::[ \t]+")) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
827 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
828 (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
|
829 "Is point at a line starting a plain-list item with a checklet?" |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
830 (org-list-at-regexp-after-bullet-p "\\(\\[[- X]\\]\\)[ \t]+")) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
831 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
832 (defun org-checkbox-blocked-p () |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
833 "Is the current checkbox blocked from for being checked now? |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
834 A checkbox is blocked if all of the following conditions are fulfilled: |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
835 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
836 1. The checkbox is not checked already. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
837 2. The current entry has the ORDERED property set. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
838 3. There is an unchecked checkbox in this entry before the current line." |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
839 (catch 'exit |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
840 (save-match-data |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
841 (save-excursion |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
842 (unless (org-at-item-checkbox-p) (throw 'exit nil)) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
843 (when (equal (match-string 1) "[X]") |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
844 ;; the box is already checked! |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
845 (throw 'exit nil)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
846 (let ((end (point-at-bol))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
847 (condition-case nil (org-back-to-heading t) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
848 (error (throw 'exit nil))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
849 (unless (org-entry-get nil "ORDERED") (throw 'exit nil)) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
850 (when (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
851 "^[ \t]*[-+*0-9.)]+[ \t]+\\(\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[[- ]\\]" end t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
852 (org-current-line))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
853 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
854 ;;; Navigate |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
855 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
856 ;; Every interactive navigation function is derived from a |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
857 ;; non-interactive one, which doesn't move point, assumes point is |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
858 ;; already in a list and doesn't compute list boundaries. |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
859 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
860 ;; If you plan to use more than one org-list function is some code, |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
861 ;; you should therefore first check if point is in a list with |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
862 ;; `org-in-item-p' or `org-at-item-p', then compute list boundaries |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
863 ;; with `org-list-top-point' and `org-list-bottom-point', and make use |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
864 ;; of non-interactive forms. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
865 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
866 (defun org-list-top-point () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
867 "Return point at the top level in a list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
868 Assume point is in a list." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
869 (let* ((prev-head (save-excursion (outline-previous-heading))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
870 (bound (if prev-head |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
871 (or (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
872 (let ((case-fold-search t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
873 (re-search-backward "^[ \t]*:END:" prev-head t))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
874 prev-head) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
875 (point-min)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
876 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
877 ((eq org-list-ending-method 'regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
878 (org-list-top-point-with-regexp bound)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
879 ((eq org-list-ending-method 'indent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
880 (org-list-top-point-with-indent bound)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
881 (t (let ((top-re (org-list-top-point-with-regexp bound))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
882 (org-list-top-point-with-indent (or top-re bound))))))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
883 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
884 (defun org-list-bottom-point () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
885 "Return point just before list ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
886 Assume point is in a list." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
887 (let* ((next-head (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
888 (and (let ((outline-regexp org-outline-regexp)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
889 ;; Use default regexp because folding |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
890 ;; changes OUTLINE-REGEXP. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
891 (outline-next-heading))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
892 (limit (or (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
893 (and (re-search-forward "^[ \t]*:END:" next-head t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
894 (point-at-bol))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
895 next-head |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
896 (point-max)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
897 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
898 ((eq org-list-ending-method 'regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
899 (org-list-bottom-point-with-regexp limit)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
900 ((eq org-list-ending-method 'indent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
901 (org-list-bottom-point-with-indent limit)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
902 (t (let ((bottom-re (org-list-bottom-point-with-regexp limit))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
903 (org-list-bottom-point-with-indent (or bottom-re limit))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
904 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
905 (defun org-get-item-beginning () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
906 "Return position of current item beginning." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
907 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
908 ;; possibly match current line |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
909 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
910 (org-search-backward-unenclosed org-item-beginning-re nil t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
911 (point-at-bol))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
912 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
913 (defun org-beginning-of-item () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
914 "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
|
915 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
|
916 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
917 (if (org-in-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
918 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
919 (error "Not in an item"))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
920 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
921 (defun org-get-beginning-of-list (top) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
922 "Return position of the first item of the current list or sublist. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
923 TOP is the position at list beginning." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
924 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
925 (let (prev-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
926 (while (setq prev-p (org-get-previous-item (point) top)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
927 (goto-char prev-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
928 (point-at-bol)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
929 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
930 (defun org-beginning-of-item-list () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
931 "Go to the beginning item of the current list or sublist. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
932 Return an error if not in a list." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
933 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
934 (if (org-in-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
935 (goto-char (org-get-beginning-of-list (org-list-top-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
936 (error "Not in an item"))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
937 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
938 (defun org-get-end-of-list (bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
939 "Return position at the end of the current list or sublist. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
940 BOTTOM is the position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
941 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
942 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
943 (let ((ind (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
944 (while (and (/= (point) bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
945 (>= (org-get-indentation) ind)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
946 (org-search-forward-unenclosed org-item-beginning-re bottom 'move)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
947 (if (= (point) bottom) bottom (point-at-bol))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
948 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
949 (defun org-end-of-item-list () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
950 "Go to the end of the current list or sublist. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
951 If the cursor in not in an item, throw an error." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
952 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
953 (if (org-in-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
954 (goto-char (org-get-end-of-list (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
955 (error "Not in an item"))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
956 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
957 (defun org-get-end-of-item (bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
958 "Return position at the end of the current item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
959 BOTTOM is the position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
960 (or (org-get-next-item (point) bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
961 (org-get-end-of-list bottom))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
962 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
963 (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
|
964 "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
|
965 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
|
966 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
967 (if (org-in-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
968 (goto-char (org-get-end-of-item (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
969 (error "Not in an item"))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
970 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
971 (defun org-end-of-item-or-at-child (bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
972 "Move to the end of the item, stops before the first child if any. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
973 BOTTOM is the position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
974 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
975 (goto-char |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
976 (if (org-search-forward-unenclosed org-item-beginning-re bottom t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
977 (point-at-bol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
978 (org-get-end-of-item bottom)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
979 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
980 (defun org-end-of-item-before-blank (bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
981 "Return point at end of item, before any blank line. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
982 Point returned is at eol. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
983 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
984 BOTTOM is the position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
985 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
986 (goto-char (org-get-end-of-item bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
987 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
988 (point-at-eol))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
989 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
990 (defun org-get-previous-item (pos limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
991 "Return point of the previous item at the same level as POS. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
992 Stop searching at LIMIT. Return nil if no item is found." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
993 (org-list-get-item-same-level |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
994 #'org-search-backward-unenclosed pos limit #'beginning-of-line)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
995 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
996 (defun org-previous-item () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
997 "Move to the beginning of the previous item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
998 Item is at the same level in the current plain list. Error if not |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
999 in a plain list, or if this is the first item in the list." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1000 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1001 (if (not (org-in-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1002 (error "Not in an item") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1003 (let ((prev-p (org-get-previous-item (point) (org-list-top-point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1004 (if prev-p (goto-char prev-p) (error "On first item"))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1005 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1006 (defun org-get-next-item (pos limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1007 "Return point of the next item at the same level as POS. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1008 Stop searching at LIMIT. Return nil if no item is found." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1009 (org-list-get-item-same-level |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1010 #'org-search-forward-unenclosed pos limit #'end-of-line)) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
1011 |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1012 (defun org-next-item () |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1013 "Move to the beginning of the next item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1014 Item is at the same level in the current plain list. Error if not |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1015 in a plain list, or if this is the last item in the list." |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1016 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1017 (if (not (org-in-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1018 (error "Not in an item") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1019 (let ((next-p (org-get-next-item (point) (org-list-bottom-point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1020 (if next-p (goto-char next-p) (error "On last item"))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1021 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1022 ;;; Manipulate |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1023 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1024 (defun org-list-exchange-items (beg-A beg-B bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1025 "Swap item starting at BEG-A with item starting at BEG-B. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1026 Blank lines at the end of items are left in place. Assume BEG-A |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1027 is lesser than BEG-B. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1028 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1029 BOTTOM is the position at list ending." |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
1030 (save-excursion |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1031 (let* ((end-of-item-no-blank |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1032 (lambda (pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1033 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1034 (goto-char (org-end-of-item-before-blank bottom)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1035 (end-A-no-blank (funcall end-of-item-no-blank beg-A)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1036 (end-B-no-blank (funcall end-of-item-no-blank beg-B)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1037 (body-A (buffer-substring beg-A end-A-no-blank)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1038 (body-B (buffer-substring beg-B end-B-no-blank)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1039 (between-A-no-blank-and-B (buffer-substring end-A-no-blank beg-B))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1040 (goto-char beg-A) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1041 (delete-region beg-A end-B-no-blank) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1042 (insert (concat body-B between-A-no-blank-and-B body-A))))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1043 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1044 (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
|
1045 "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
|
1046 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
|
1047 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
|
1048 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1049 (if (not (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1050 (error "Not at an item") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1051 (let* ((pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1052 (col (current-column)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1053 (bottom (org-list-bottom-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1054 (actual-item (goto-char (org-get-item-beginning))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1055 (next-item (org-get-next-item (point) bottom))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1056 (if (not next-item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1057 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1058 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1059 (error "Cannot move this item further down")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1060 (org-list-exchange-items actual-item next-item bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1061 (org-list-repair nil nil bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1062 (goto-char (org-get-next-item (point) bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1063 (move-to-column col))))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1064 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1065 (defun org-move-item-up () |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1066 "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
|
1067 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
|
1068 so this really moves item trees." |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1069 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1070 (if (not (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1071 (error "Not at an item") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1072 (let* ((pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1073 (col (current-column)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1074 (top (org-list-top-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1075 (bottom (org-list-bottom-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1076 (actual-item (goto-char (org-get-item-beginning))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1077 (prev-item (org-get-previous-item (point) top))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1078 (if (not prev-item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1079 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1080 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1081 (error "Cannot move this item further up")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1082 (org-list-exchange-items prev-item actual-item bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1083 (org-list-repair nil top bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1084 (move-to-column col))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1085 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1086 (defun org-insert-item (&optional checkbox) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1087 "Insert a new item at the current level. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1088 If cursor is before first character after bullet of the item, the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1089 new item will be created before the current one. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1090 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1091 If CHECKBOX is non-nil, add a checkbox next to the bullet. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1092 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1093 Return t when things worked, nil when we are not in an item, or |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1094 item is invisible." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1095 (unless (or (not (org-in-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1096 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1097 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1098 (org-invisible-p))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1099 (if (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1100 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1101 (org-at-item-timer-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1102 ;; Timer list: delegate to `org-timer-item'. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1103 (progn (org-timer-item) t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1104 ;; if we're in a description list, ask for the new term. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1105 (let ((desc-text (when (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1106 (and (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1107 (org-at-item-description-p))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1108 (concat (read-string "Term: ") " :: ")))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1109 ;; Don't insert a checkbox if checkbox rule is applied and it |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1110 ;; is a description item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1111 (org-list-insert-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1112 (point) (and checkbox |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1113 (or (not desc-text) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1114 (not (cdr (assq 'checkbox org-list-automatic-rules))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1115 desc-text))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1116 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1117 ;;; Structures |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1118 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1119 ;; The idea behind structures is to avoid moving back and forth in the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1120 ;; buffer on costly operations like indenting or fixing bullets. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1121 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1122 ;; It achieves this by taking a snapshot of an interesting part of the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1123 ;; list, in the shape of an alist, using `org-list-struct'. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1124 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1125 ;; It then proceeds to changes directly on the alist, with the help of |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1126 ;; and `org-list-struct-origins'. When those are done, |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1127 ;; `org-list-struct-apply-struct' applies the changes to the buffer. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1128 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1129 (defun org-list-struct-assoc-at-point () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1130 "Return the structure association at point. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1131 It is a cons-cell whose key is point and values are indentation, |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1132 bullet string and bullet counter, if any." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1133 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1134 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1135 (list (point-at-bol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1136 (org-get-indentation) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1137 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1138 (looking-at "^[ \t]*\\([-+*0-9.)]+[ \t]+\\)") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1139 (match-string 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1140 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1141 (goto-char (match-end 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1142 (and (looking-at "\\[@\\(?:start:\\)?\\([0-9]+\\)\\]") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1143 (match-string 1)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1144 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1145 (defun org-list-struct (begin end top bottom &optional outdent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1146 "Return the structure containing the list between BEGIN and END. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1147 A structure is an alist where key is point of item and values |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1148 are, in that order, indentation, bullet string and value of |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1149 counter, if any. A structure contains every list and sublist that |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1150 has items between BEGIN and END along with their common ancestor. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1151 If no such ancestor can be found, the function will add a virtual |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1152 ancestor at position 0. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1153 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1154 TOP and BOTTOM are respectively the position of list beginning |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1155 and list ending. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1156 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1157 If OUTDENT is non-nil, it will also grab all of the parent list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1158 and the grand-parent. Setting OUTDENT to t is mandatory when next |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1159 change is an outdent." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1160 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1161 (let* (struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1162 (extend |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1163 (lambda (struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1164 (let* ((ind-min (apply 'min (mapcar 'cadr struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1165 (begin (caar struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1166 (end (caar (last struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1167 pre-list post-list) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1168 (goto-char begin) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1169 ;; Find beginning of most outdented list (min list) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1170 (while (and (org-search-backward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1171 org-item-beginning-re top t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1172 (>= (org-get-indentation) ind-min)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1173 (setq pre-list (cons (org-list-struct-assoc-at-point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1174 pre-list))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1175 ;; Now get the parent. If none, add a virtual ancestor |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1176 (if (< (org-get-indentation) ind-min) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1177 (setq pre-list (cons (org-list-struct-assoc-at-point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1178 pre-list)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1179 (setq pre-list (cons (list 0 (org-get-indentation) "" nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1180 pre-list))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1181 ;; Find end of min list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1182 (goto-char end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1183 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1184 (while (and (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1185 org-item-beginning-re bottom 'move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1186 (>= (org-get-indentation) ind-min)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1187 (setq post-list (cons (org-list-struct-assoc-at-point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1188 post-list))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1189 ;; Is list is malformed? If some items are less |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1190 ;; indented that top-item, add them anyhow. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1191 (when (and (= (caar pre-list) 0) (< (point) bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1192 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1193 (while (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1194 org-item-beginning-re bottom t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1195 (setq post-list (cons (org-list-struct-assoc-at-point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1196 post-list)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1197 (append pre-list struct (reverse post-list)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1198 ;; Here we start: first get the core zone... |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1199 (goto-char end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1200 (while (org-search-backward-unenclosed org-item-beginning-re begin t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1201 (setq struct (cons (org-list-struct-assoc-at-point) struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1202 ;; ... then, extend it to make it a structure... |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1203 (let ((extended (funcall extend struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1204 ;; ... twice when OUTDENT is non-nil and struct still can be |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1205 ;; extended |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1206 (if (and outdent (> (caar extended) 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1207 (funcall extend extended) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1208 extended))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1209 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1210 (defun org-list-struct-origins (struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1211 "Return an alist where key is item's position and value parent's. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1212 STRUCT is the list's structure looked up." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1213 (let* ((struct-rev (reverse struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1214 (acc (list (cons (nth 1 (car struct)) 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1215 (prev-item (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1216 (car (nth 1 (member (assq item struct) struct-rev))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1217 (get-origins |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1218 (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1219 (let* ((item-pos (car item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1220 (ind (nth 1 item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1221 (prev-ind (caar acc))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1222 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1223 ;; List closing. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1224 ((> prev-ind ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1225 (let ((current-origin (or (member (assq ind acc) acc) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1226 ;; needed if top-point is |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1227 ;; not the most outdented |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1228 (last acc)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1229 (setq acc current-origin) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1230 (cons item-pos (cdar acc)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1231 ;; New list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1232 ((< prev-ind ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1233 (let ((origin (funcall prev-item item-pos))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1234 (setq acc (cons (cons ind origin) acc)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1235 (cons item-pos origin))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1236 ;; Current list going on |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1237 (t (cons item-pos (cdar acc)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1238 (cons '(0 . 0) (mapcar get-origins (cdr struct))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1239 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1240 (defun org-list-struct-get-parent (item struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1241 "Return parent association of ITEM in STRUCT or nil. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1242 ORIGINS is the alist of parents. See `org-list-struct-origins'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1243 (let* ((parent-pos (cdr (assq (car item) origins)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1244 (when (> parent-pos 0) (assq parent-pos struct)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1245 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1246 (defun org-list-struct-get-child (item struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1247 "Return child association of ITEM in STRUCT or nil." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1248 (let ((ind (nth 1 item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1249 (next-item (cadr (member item struct)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1250 (when (and next-item (> (nth 1 next-item) ind)) next-item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1251 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1252 (defun org-list-struct-fix-bul (struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1253 "Verify and correct bullets for every association in STRUCT. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1254 ORIGINS is the alist of parents. See `org-list-struct-origins'. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1255 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1256 This function modifies STRUCT." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1257 (let* (acc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1258 (init-bul (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1259 (let ((counter (nth 3 item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1260 (bullet (org-list-bullet-string (nth 2 item)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1261 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1262 ((and (string-match "[0-9]+" bullet) counter) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1263 (replace-match counter nil nil bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1264 ((string-match "[0-9]+" bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1265 (replace-match "1" nil nil bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1266 (t bullet))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1267 (set-bul (lambda (item bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1268 (setcdr item (list (nth 1 item) bullet (nth 3 item))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1269 (get-bul (lambda (item bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1270 (let* ((counter (nth 3 item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1271 (if (and counter (string-match "[0-9]+" bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1272 (replace-match counter nil nil bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1273 bullet)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1274 (fix-bul |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1275 (lambda (item) struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1276 (let* ((parent (cdr (assq (car item) origins))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1277 (orig-ref (assq parent acc))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1278 (if orig-ref |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1279 ;; Continuing previous list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1280 (let* ((prev-bul (cdr orig-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1281 (new-bul (funcall get-bul item prev-bul))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1282 (setcdr orig-ref (org-list-inc-bullet-maybe new-bul)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1283 (funcall set-bul item new-bul)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1284 ;; A new list is starting |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1285 (let ((new-bul (funcall init-bul item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1286 (funcall set-bul item new-bul) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1287 (setq acc (cons (cons parent |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1288 (org-list-inc-bullet-maybe new-bul)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1289 acc)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1290 (mapc fix-bul (cdr struct)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1291 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1292 (defun org-list-struct-fix-ind (struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1293 "Verify and correct indentation for every association in STRUCT. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1294 ORIGINS is the alist of parents. See `org-list-struct-origins'. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1295 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1296 This function modifies STRUCT." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1297 (let* ((headless (cdr struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1298 (ancestor (car struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1299 (top-ind (+ (nth 1 ancestor) (length (nth 2 ancestor)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1300 (new-ind |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1301 (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1302 (let* ((parent (org-list-struct-get-parent item headless origins))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1303 (if parent |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1304 ;; Indent like parent + length of parent's bullet |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1305 (setcdr item (cons (+ (length (nth 2 parent)) (nth 1 parent)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1306 (cddr item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1307 ;; If no parent, indent like top-point |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1308 (setcdr item (cons top-ind (cddr item)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1309 (mapc new-ind headless))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1310 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1311 (defun org-list-struct-fix-struct (struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1312 "Return STRUCT with correct bullets and indentation. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1313 ORIGINS is the alist of parents. See `org-list-struct-origins'. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1314 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1315 Only elements of STRUCT that have changed are returned." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1316 (let ((old (copy-alist struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1317 (org-list-struct-fix-bul struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1318 (org-list-struct-fix-ind struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1319 (delq nil (mapcar (lambda (e) (when (not (equal (pop old) e)) e)) struct)))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1320 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1321 (defun org-list-struct-outdent (start end origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1322 "Outdent items in a structure. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1323 Items are indented when their key is between START, included, and |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1324 END, excluded. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1325 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1326 ORIGINS is the alist of parents. See `org-list-struct-origins'. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1327 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1328 STRUCT is the concerned structure." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1329 (let* (acc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1330 (out (lambda (cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1331 (let* ((item (car cell)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1332 (parent (cdr cell))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1333 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1334 ;; Item not yet in zone: keep association |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1335 ((< item start) cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1336 ;; Item out of zone: follow associations in acc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1337 ((>= item end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1338 (let ((convert (assq parent acc))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1339 (if convert (cons item (cdr convert)) cell))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1340 ;; Item has no parent: error |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1341 ((<= parent 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1342 (error "Cannot outdent top-level items")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1343 ;; Parent is outdented: keep association |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1344 ((>= parent start) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1345 (setq acc (cons (cons parent item) acc)) cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1346 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1347 ;; Parent isn't outdented: reparent to grand-parent |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1348 (let ((grand-parent (cdr (assq parent origins)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1349 (setq acc (cons (cons parent item) acc)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1350 (cons item grand-parent)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1351 (mapcar out origins))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1352 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1353 (defun org-list-struct-indent (start end origins struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1354 "Indent items in a structure. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1355 Items are indented when their key is between START, included, and |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1356 END, excluded. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1357 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1358 ORIGINS is the alist of parents. See `org-list-struct-origins'. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1359 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1360 STRUCT is the concerned structure. It may be modified if |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1361 `org-list-demote-modify-bullet' matches bullets between START and |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1362 END." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1363 (let* (acc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1364 (orig-rev (reverse origins)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1365 (get-prev-item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1366 (lambda (cell parent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1367 (car (rassq parent (cdr (memq cell orig-rev)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1368 (set-assoc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1369 (lambda (cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1370 (setq acc (cons cell acc)) cell)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1371 (change-bullet-maybe |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1372 (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1373 (let* ((full-item (assq item struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1374 (item-bul (org-trim (nth 2 full-item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1375 (new-bul-p (cdr (assoc item-bul org-list-demote-modify-bullet)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1376 (when new-bul-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1377 ;; new bullet is stored without space to ensure item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1378 ;; will be modified |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1379 (setcdr full-item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1380 (list (nth 1 full-item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1381 new-bul-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1382 (nth 3 full-item))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1383 (ind |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1384 (lambda (cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1385 (let* ((item (car cell)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1386 (parent (cdr cell))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1387 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1388 ;; Item not yet in zone: keep association |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1389 ((< item start) cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1390 ((>= item end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1391 ;; Item out of zone: follow associations in acc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1392 (let ((convert (assq parent acc))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1393 (if convert (cons item (cdr convert)) cell))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1394 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1395 ;; Item is in zone... |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1396 (let ((prev (funcall get-prev-item cell parent))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1397 ;; Check if bullet needs to be changed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1398 (funcall change-bullet-maybe item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1399 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1400 ;; First item indented but not parent: error |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1401 ((and (or (not prev) (= prev 0)) (< parent start)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1402 (error "Cannot indent the first item of a list")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1403 ;; First item and parent indented: keep same parent |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1404 ((or (not prev) (= prev 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1405 (funcall set-assoc cell)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1406 ;; Previous item not indented: reparent to it |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1407 ((< prev start) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1408 (funcall set-assoc (cons item prev))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1409 ;; Previous item indented: reparent like it |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1410 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1411 (funcall set-assoc (cons item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1412 (cdr (assq prev acc))))))))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1413 (mapcar ind origins))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1414 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1415 (defun org-list-struct-apply-struct (struct bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1416 "Apply modifications to list so it mirrors STRUCT. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1417 BOTTOM is position at list ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1418 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1419 Initial position is restored after the changes." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1420 (let* ((pos (copy-marker (point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1421 (ancestor (caar struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1422 (modify |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1423 (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1424 (goto-char (car item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1425 (let* ((new-ind (nth 1 item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1426 (new-bul (org-list-bullet-string (nth 2 item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1427 (old-ind (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1428 (old-bul (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1429 (looking-at "[ \t]*\\(\\S-+[ \t]*\\)") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1430 (match-string 1))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1431 (old-body-ind (+ (length old-bul) old-ind)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1432 (new-body-ind (+ (length new-bul) new-ind))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1433 ;; 1. Shift item's body |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1434 (unless (= old-body-ind new-body-ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1435 (org-shift-item-indentation |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1436 (- new-body-ind old-body-ind) bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1437 ;; 2. Replace bullet |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1438 (unless (equal new-bul old-bul) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1439 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1440 (looking-at "[ \t]*\\(\\S-+[ \t]*\\)") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1441 (replace-match new-bul nil nil nil 1))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1442 ;; 3. Indent item to appropriate column |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1443 (unless (= new-ind old-ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1444 (delete-region (point-at-bol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1445 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1446 (skip-chars-forward " \t") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1447 (point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1448 (indent-to new-ind))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1449 ;; Remove ancestor if it is left. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1450 (struct-to-apply (if (or (not ancestor) (= 0 ancestor)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1451 (cdr struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1452 struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1453 ;; Apply changes from bottom to top |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1454 (mapc modify (nreverse struct-to-apply)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1455 (goto-char pos))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1456 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1457 ;;; Indentation |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1458 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1459 (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
|
1460 "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
|
1461 (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
|
1462 (catch 'exit |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1463 (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
|
1464 (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
|
1465 (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
|
1466 ((= 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
|
1467 (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
|
1468 i)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1469 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1470 (defun org-shift-item-indentation (delta bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1471 "Shift the indentation in current item by DELTA. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1472 Sub-items are not moved. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1473 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1474 BOTTOM is position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1475 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1476 (let ((beg (point-at-bol)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1477 (end (org-end-of-item-or-at-child bottom))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1478 (beginning-of-line (unless (eolp) 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1479 (while (> (point) beg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1480 (when (looking-at "[ \t]*\\S-") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1481 ;; this is not an empty line |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1482 (let ((i (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1483 (when (and (> i 0) (> (+ i delta) 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1484 (indent-line-to (+ i delta))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1485 (beginning-of-line 0))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1486 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1487 (defun org-outdent-item () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1488 "Outdent a local list item, but not its children. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1489 If a region is active, all items inside will be moved." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1490 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1491 (org-list-indent-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1492 -1 t (org-list-top-point) (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1493 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1494 (defun org-indent-item () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1495 "Indent a local list item, but not its children. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1496 If a region is active, all items inside will be moved." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1497 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1498 (org-list-indent-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1499 1 t (org-list-top-point) (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1500 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1501 (defun org-outdent-item-tree () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1502 "Outdent a local list item including its children. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1503 If a region is active, all items inside will be moved." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1504 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1505 (org-list-indent-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1506 -1 nil (org-list-top-point) (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1507 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1508 (defun org-indent-item-tree () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1509 "Indent a local list item including its children. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1510 If a region is active, all items inside will be moved." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1511 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1512 (org-list-indent-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1513 1 nil (org-list-top-point) (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1514 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1515 (defvar org-tab-ind-state) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1516 (defun org-cycle-item-indentation () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1517 "Cycle levels of indentation of an empty item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1518 The first run indent the item, if applicable. Subsequents runs |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1519 outdent it at meaningful levels in the list. When done, item is |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1520 put back at its original position with its original bullet. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1521 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1522 Return t at each successful move." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1523 (let ((org-adapt-indentation nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1524 (ind (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1525 (bottom (and (org-at-item-p) (org-list-bottom-point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1526 (when (and (or (org-at-item-description-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1527 (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1528 (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1529 ;; Check that item is really empty |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1530 (>= (match-end 0) (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1531 (org-end-of-item-or-at-child bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1532 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1533 (point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1534 (setq this-command 'org-cycle-item-indentation) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1535 (let ((top (org-list-top-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1536 ;; When in the middle of the cycle, try to outdent first. If it |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1537 ;; fails, and point is still at initial position, indent. Else, |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1538 ;; go back to original position. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1539 (if (eq last-command 'org-cycle-item-indentation) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1540 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1541 ((ignore-errors (org-list-indent-item-generic -1 t top bottom))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1542 ((and (= (org-get-indentation) (car org-tab-ind-state)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1543 (ignore-errors |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1544 (org-list-indent-item-generic 1 t top bottom)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1545 (t (back-to-indentation) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1546 (indent-to-column (car org-tab-ind-state)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1547 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1548 (org-list-repair (cdr org-tab-ind-state)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1549 ;; Break cycle |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1550 (setq this-command 'identity))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1551 ;; If a cycle is starting, remember indentation and bullet, |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1552 ;; then try to indent. If it fails, try to outdent. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1553 (setq org-tab-ind-state (cons ind (org-get-bullet))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1554 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1555 ((ignore-errors (org-list-indent-item-generic 1 t top bottom))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1556 ((ignore-errors (org-list-indent-item-generic -1 t top bottom))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1557 (t (error "Cannot move item"))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1558 t))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1559 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1560 ;;; Bullets |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1561 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1562 (defun org-get-bullet () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1563 "Return the bullet of the item at point. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1564 Assume cursor is at an item." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1565 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1566 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1567 (and (looking-at "[ \t]*\\(\\S-+\\)") (match-string 1)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1568 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1569 (defun org-list-bullet-string (bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1570 "Return BULLET with the correct number of whitespaces. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1571 It determines the number of whitespaces to append by looking at |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1572 `org-list-two-spaces-after-bullet-regexp'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1573 (save-match-data |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1574 (string-match "\\S-+\\([ \t]*\\)" bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1575 (replace-match |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1576 (save-match-data |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1577 (concat |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1578 " " |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1579 ;; Do we need to concat another white space ? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1580 (when (and org-list-two-spaces-after-bullet-regexp |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1581 (string-match org-list-two-spaces-after-bullet-regexp bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1582 " "))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1583 nil nil bullet 1))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1584 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1585 (defun org-list-inc-bullet-maybe (bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1586 "Increment BULLET if applicable." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1587 (if (string-match "[0-9]+" bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1588 (replace-match |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1589 (number-to-string (1+ (string-to-number (match-string 0 bullet)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1590 nil nil bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1591 bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1592 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1593 (defun org-list-repair (&optional force-bullet top bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1594 "Make sure all items are correctly indented, with the right bullet. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1595 This function scans the list at point, along with any sublist. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1596 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1597 If FORCE-BULLET is a string, ensure all items in list share this |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1598 bullet, or a logical successor in the case of an ordered list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1599 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1600 When non-nil, TOP and BOTTOM specify respectively position of |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1601 list beginning and list ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1602 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1603 Item's body is not indented, only shifted with the bullet." |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1604 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1605 (unless (org-at-item-p) (error "This is not a list")) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1606 (let* ((bottom (or bottom (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1607 (struct (org-list-struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1608 (point-at-bol) (point-at-eol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1609 (or top (org-list-top-point)) bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1610 (origins (org-list-struct-origins struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1611 fixed-struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1612 (if (stringp force-bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1613 (let ((begin (nth 1 struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1614 (setcdr begin (list (nth 1 begin) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1615 (org-list-bullet-string force-bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1616 (nth 3 begin))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1617 (setq fixed-struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1618 (cons begin (org-list-struct-fix-struct struct origins)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1619 (setq fixed-struct (org-list-struct-fix-struct struct origins))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1620 (org-list-struct-apply-struct fixed-struct bottom))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1621 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1622 (defun org-cycle-list-bullet (&optional which) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1623 "Cycle through the different itemize/enumerate bullets. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1624 This cycle the entire list level through the sequence: |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1625 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1626 `-' -> `+' -> `*' -> `1.' -> `1)' |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1627 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1628 If WHICH is a valid string, use that as the new bullet. If WHICH |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1629 is an integer, 0 means `-', 1 means `+' etc. If WHICH is |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1630 'previous, cycle backwards." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1631 (interactive "P") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1632 (let* ((top (org-list-top-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1633 (bullet (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1634 (goto-char (org-get-beginning-of-list top)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1635 (org-get-bullet))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1636 (current (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1637 ((string-match "\\." bullet) "1.") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1638 ((string-match ")" bullet) "1)") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1639 (t bullet))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1640 (bullet-rule-p (cdr (assq 'bullet org-list-automatic-rules))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1641 (bullet-list (append '("-" "+" ) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1642 ;; *-bullets are not allowed at column 0 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1643 (unless (and bullet-rule-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1644 (looking-at "\\S-")) '("*")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1645 ;; Description items cannot be numbered |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1646 (unless (and bullet-rule-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1647 (or (eq org-plain-list-ordered-item-terminator ?\)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1648 (org-at-item-description-p))) '("1.")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1649 (unless (and bullet-rule-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1650 (or (eq org-plain-list-ordered-item-terminator ?.) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1651 (org-at-item-description-p))) '("1)")))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1652 (len (length bullet-list)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1653 (item-index (- len (length (member current bullet-list)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1654 (get-value (lambda (index) (nth (mod index len) bullet-list))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1655 (new (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1656 ((member which bullet-list) which) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1657 ((numberp which) (funcall get-value which)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1658 ((eq 'previous which) (funcall get-value (1- item-index))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1659 (t (funcall get-value (1+ item-index)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1660 (org-list-repair new top))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1661 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1662 ;;; Checkboxes |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1663 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1664 (defun org-toggle-checkbox (&optional toggle-presence) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1665 "Toggle the checkbox in the current line. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1666 With prefix arg TOGGLE-PRESENCE, add or remove checkboxes. With |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1667 double prefix, set checkbox to [-]. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1668 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1669 When there is an active region, toggle status or presence of the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1670 first checkbox there, and make every item inside have the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1671 same status or presence, respectively. |
99849
621e15919df0
2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99501
diff
changeset
|
1672 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1673 If the cursor is in a headline, apply this to all checkbox items |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1674 in the text below the heading, taking as reference the first item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1675 in subtree, ignoring drawers." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1676 (interactive "P") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1677 ;; Bounds is a list of type (beg end single-p) where single-p is t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1678 ;; when `org-toggle-checkbox' is applied to a single item. Only |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1679 ;; toggles on single items will return errors. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1680 (let* ((bounds |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1681 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1682 ((org-region-active-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1683 (let ((rbeg (region-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1684 (rend (region-end))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1685 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1686 (goto-char rbeg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1687 (if (org-search-forward-unenclosed org-item-beginning-re rend 'move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1688 (list (point-at-bol) rend nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1689 (error "No item in region"))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1690 ((org-on-heading-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1691 ;; In this case, reference line is the first item in |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1692 ;; subtree outside drawers |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1693 (let ((pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1694 (limit (save-excursion (outline-next-heading) (point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1695 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1696 (goto-char limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1697 (org-search-backward-unenclosed ":END:" pos 'move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1698 (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1699 org-item-beginning-re limit 'move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1700 (list (point) limit nil)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1701 ((org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1702 (list (point-at-bol) (1+ (point-at-eol)) t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1703 (t (error "Not at an item or heading, and no active region")))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1704 (beg (car bounds)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1705 ;; marker is needed because deleting or inserting checkboxes |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1706 ;; will change bottom point |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1707 (end (copy-marker (nth 1 bounds))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1708 (single-p (nth 2 bounds)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1709 (ref-presence (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1710 (goto-char beg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1711 (org-at-item-checkbox-p))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1712 (ref-status (equal (match-string 1) "[X]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1713 (act-on-item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1714 (lambda (ref-pres ref-stat) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1715 (if (equal toggle-presence '(4)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1716 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1717 ((and ref-pres (org-at-item-checkbox-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1718 (replace-match "")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1719 ((and (not ref-pres) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1720 (not (org-at-item-checkbox-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1721 (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1722 (goto-char (match-end 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1723 ;; Ignore counter, if any |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1724 (when (looking-at "\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1725 (goto-char (match-end 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1726 (let ((desc-p (and (org-at-item-description-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1727 (cdr (assq 'checkbox org-list-automatic-rules))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1728 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1729 ((and single-p desc-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1730 (error "Cannot add a checkbox in a description list")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1731 ((not desc-p) (insert "[ ] ")))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1732 (let ((blocked (org-checkbox-blocked-p))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1733 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1734 ((and blocked single-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1735 (error "Checkbox blocked because of unchecked box in line %d" blocked)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1736 (blocked nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1737 ((org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1738 (replace-match |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1739 (cond ((equal toggle-presence '(16)) "[-]") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1740 (ref-stat "[ ]") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1741 (t "[X]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1742 t t nil 1)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1743 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1744 (goto-char beg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1745 (while (< (point) end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1746 (funcall act-on-item ref-presence ref-status) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1747 (org-search-forward-unenclosed org-item-beginning-re end 'move))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1748 (org-update-checkbox-count-maybe))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1749 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1750 (defun org-reset-checkbox-state-subtree () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1751 "Reset all checkboxes in an entry subtree." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1752 (interactive "*") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1753 (save-restriction |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1754 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1755 (org-narrow-to-subtree) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1756 (org-show-subtree) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1757 (goto-char (point-min)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1758 (let ((end (point-max))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1759 (while (< (point) end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1760 (when (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1761 (replace-match "[ ]" t t nil 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1762 (beginning-of-line 2)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1763 (org-update-checkbox-count-maybe))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1764 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1765 (defvar org-checkbox-statistics-hook nil |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1766 "Hook that is run whenever Org thinks checkbox statistics should be updated. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1767 This hook runs even if checkbox rule in |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1768 `org-list-automatic-rules' does not apply, so it can be used to |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1769 implement alternative ways of collecting statistics |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1770 information.") |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1771 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1772 (defun org-update-checkbox-count-maybe () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1773 "Update checkbox statistics unless turned off by user." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1774 (when (cdr (assq 'checkbox org-list-automatic-rules)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1775 (org-update-checkbox-count)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1776 (run-hooks 'org-checkbox-statistics-hook)) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
1777 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1778 (defun org-update-checkbox-count (&optional all) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1779 "Update the checkbox statistics in the current section. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1780 This will find all statistic cookies like [57%] and [6/12] and update them |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1781 with the current numbers. With optional prefix argument ALL, do this for |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1782 the whole buffer." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1783 (interactive "P") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1784 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1785 (let ((cstat 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1786 (catch 'exit |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1787 (while t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1788 (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1789 (beg (condition-case nil |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1790 (progn (org-back-to-heading) (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1791 (error (point-min)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1792 (end (copy-marker (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1793 (outline-next-heading) (point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1794 (re-cookie "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1795 (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\(\\[[- X]\\]\\)") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1796 beg-cookie end-cookie is-percent c-on c-off lim new |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1797 curr-ind next-ind continue-from startsearch list-beg list-end |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1798 (recursive |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1799 (or (not org-hierarchical-checkbox-statistics) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1800 (string-match "\\<recursive\\>" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1801 (or (ignore-errors |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1802 (org-entry-get nil "COOKIE_DATA")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1803 ""))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1804 (goto-char end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1805 ;; find each statistics cookie |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1806 (while (and (org-search-backward-unenclosed re-cookie beg 'move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1807 (not (save-match-data |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1808 (and (org-on-heading-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1809 (string-match "\\<todo\\>" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1810 (downcase |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1811 (or (org-entry-get |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1812 nil "COOKIE_DATA") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1813 ""))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1814 (setq beg-cookie (match-beginning 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1815 end-cookie (match-end 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1816 cstat (+ cstat (if end-cookie 1 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1817 startsearch (point-at-eol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1818 continue-from (match-beginning 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1819 is-percent (match-beginning 2) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1820 lim (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1821 ((org-on-heading-p) (outline-next-heading) (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1822 ;; Ensure many cookies in the same list won't imply |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1823 ;; computing list boundaries as many times. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1824 ((org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1825 (unless (and list-beg (>= (point) list-beg)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1826 (setq list-beg (org-list-top-point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1827 list-end (copy-marker |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1828 (org-list-bottom-point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1829 (org-get-end-of-item list-end)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1830 (t nil)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1831 c-on 0 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1832 c-off 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1833 (when lim |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1834 ;; find first checkbox for this cookie and gather |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1835 ;; statistics from all that are at this indentation level |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1836 (goto-char startsearch) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1837 (if (org-search-forward-unenclosed re-box lim t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1838 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1839 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1840 (setq curr-ind (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1841 (setq next-ind curr-ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1842 (while (and (bolp) (org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1843 (if recursive |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1844 (<= curr-ind next-ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1845 (= curr-ind next-ind))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1846 (when (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1847 (if (member (match-string 1) '("[ ]" "[-]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1848 (setq c-off (1+ c-off)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1849 (setq c-on (1+ c-on)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1850 (if (not recursive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1851 ;; org-get-next-item goes through list-enders |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1852 ;; with proper limit. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1853 (goto-char (or (org-get-next-item (point) lim) lim)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1854 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1855 (when (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1856 org-item-beginning-re lim t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1857 (beginning-of-line))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1858 (setq next-ind (org-get-indentation))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1859 (goto-char continue-from) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1860 ;; update cookie |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1861 (when end-cookie |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1862 (setq new (if is-percent |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1863 (format "[%d%%]" (/ (* 100 c-on) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1864 (max 1 (+ c-on c-off)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1865 (format "[%d/%d]" c-on (+ c-on c-off)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1866 (goto-char beg-cookie) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1867 (insert new) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1868 (delete-region (point) (+ (point) (- end-cookie beg-cookie)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1869 ;; update items checkbox if it has one |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1870 (when (and (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1871 (> (+ c-on c-off) 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1872 (setq beg-cookie (match-beginning 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1873 end-cookie (match-end 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1874 (delete-region beg-cookie end-cookie) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1875 (goto-char beg-cookie) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1876 (cond ((= c-off 0) (insert "[X]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1877 ((= c-on 0) (insert "[ ]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1878 (t (insert "[-]"))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1879 (goto-char continue-from))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1880 (unless (and all (outline-next-heading)) (throw 'exit nil)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1881 (when (interactive-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1882 (message "Checkbox statistics updated %s (%d places)" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1883 (if all "in entire file" "in current outline entry") cstat))))) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
1884 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1885 (defun org-get-checkbox-statistics-face () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1886 "Select the face for checkbox statistics. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1887 The face will be `org-done' when all relevant boxes are checked. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1888 Otherwise it will be `org-todo'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1889 (if (match-end 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1890 (if (equal (match-string 1) "100%") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1891 'org-checkbox-statistics-done |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1892 'org-checkbox-statistics-todo) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1893 (if (and (> (match-end 2) (match-beginning 2)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1894 (equal (match-string 2) (match-string 3))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1895 'org-checkbox-statistics-done |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1896 'org-checkbox-statistics-todo))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1897 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1898 ;;; Misc Tools |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1899 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1900 (defun org-apply-on-list (function init-value &rest args) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1901 "Call FUNCTION on each item of the list at point. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1902 FUNCTION must be called with at least one argument: INIT-VALUE, |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1903 that will contain the value returned by the function at the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1904 previous item, plus ARGS extra arguments. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1905 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1906 As an example, (org-apply-on-list (lambda (result) (1+ result)) 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1907 will return the number of items in the current list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1908 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1909 Sublists of the list are skipped. Cursor is always at the |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1910 beginning of the item." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1911 (let* ((pos (copy-marker (point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1912 (end (copy-marker (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1913 (next-p (copy-marker (org-get-beginning-of-list (org-list-top-point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1914 (value init-value)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1915 (while (< next-p end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1916 (goto-char next-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1917 (set-marker next-p (or (org-get-next-item (point) end) end)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1918 (setq value (apply function value args))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1919 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1920 value)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1921 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1922 (defun org-sort-list (&optional with-case sorting-type getkey-func compare-func) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1923 "Sort plain list items. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1924 The cursor may be at any item of the list that should be sorted. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1925 Sublists are not sorted. Checkboxes, if any, are ignored. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1926 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1927 Sorting can be alphabetically, numerically, by date/time as given by |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1928 a time stamp, by a property or by priority. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1929 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1930 Comparing entries ignores case by default. However, with an |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1931 optional argument WITH-CASE, the sorting considers case as well. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1932 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1933 The command prompts for the sorting type unless it has been given |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1934 to the function through the SORTING-TYPE argument, which needs to |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1935 be a character, \(?n ?N ?a ?A ?t ?T ?f ?F). Here is the precise |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1936 meaning of each character: |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1937 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1938 n Numerically, by converting the beginning of the item to a number. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1939 a Alphabetically. Only the first line of item is checked. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1940 t By date/time, either the first active time stamp in the entry, if |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1941 any, or by the first inactive one. In a timer list, sort the timers. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1942 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1943 Capital letters will reverse the sort order. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1944 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1945 If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies a |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1946 function to be called with point at the beginning of the record. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1947 It must return either a string or a number that should serve as |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1948 the sorting key for that record. It will then use COMPARE-FUNC to |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1949 compare entries." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1950 (interactive "P") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1951 (let* ((case-func (if with-case 'identity 'downcase)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1952 (top (org-list-top-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1953 (bottom (org-list-bottom-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1954 (start (org-get-beginning-of-list top)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1955 (end (org-get-end-of-list bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1956 (sorting-type |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1957 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1958 (message |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1959 "Sort plain list: [a]lpha [n]umeric [t]ime [f]unc A/N/T/F means reversed:") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1960 (read-char-exclusive))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1961 (getkey-func (and (= (downcase sorting-type) ?f) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1962 (org-icompleting-read "Sort using function: " |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1963 obarray 'fboundp t nil nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1964 (intern getkey-func)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1965 (message "Sorting items...") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1966 (save-restriction |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1967 (narrow-to-region start end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1968 (goto-char (point-min)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1969 (let* ((dcst (downcase sorting-type)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1970 (case-fold-search nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1971 (now (current-time)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1972 (sort-func (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1973 ((= dcst ?a) 'string<) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1974 ((= dcst ?f) compare-func) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1975 ((= dcst ?t) '<) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1976 (t nil))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1977 (begin-record (lambda () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1978 (skip-chars-forward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1979 (beginning-of-line))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1980 (end-record (lambda () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1981 (goto-char (org-end-of-item-before-blank end)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1982 (value-to-sort |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1983 (lambda () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1984 (when (looking-at "[ \t]*[-+*0-9.)]+\\([ \t]+\\[[- X]\\]\\)?[ \t]+") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1985 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1986 ((= dcst ?n) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1987 (string-to-number (buffer-substring (match-end 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1988 (point-at-eol)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1989 ((= dcst ?a) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1990 (buffer-substring (match-end 0) (point-at-eol))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1991 ((= dcst ?t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1992 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1993 ;; If it is a timer list, convert timer to seconds |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1994 ((org-at-item-timer-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1995 (org-timer-hms-to-secs (match-string 1))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1996 ((or (org-search-forward-unenclosed org-ts-regexp |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1997 (point-at-eol) t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1998 (org-search-forward-unenclosed org-ts-regexp-both |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1999 (point-at-eol) t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2000 (org-time-string-to-seconds (match-string 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2001 (t (org-float-time now)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2002 ((= dcst ?f) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2003 (if getkey-func |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2004 (let ((value (funcall getkey-func))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2005 (if (stringp value) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2006 (funcall case-func value) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2007 value)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2008 (error "Invalid key function `%s'" getkey-func))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2009 (t (error "Invalid sorting type `%c'" sorting-type))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2010 (sort-subr (/= dcst sorting-type) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2011 begin-record |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2012 end-record |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2013 value-to-sort |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2014 nil |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2015 sort-func) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2016 (org-list-repair nil top bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2017 (run-hooks 'org-after-sorting-entries-or-items-hook) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2018 (message "Sorting items...done"))))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2019 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2020 ;;; 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
|
2021 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2022 (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
|
2023 "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
|
2024 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
|
2025 sublevels as a list of strings." |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2026 (let* ((start (goto-char (org-list-top-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2027 (end (org-list-bottom-point)) |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2028 output itemsep ltype) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2029 (while (org-search-forward-unenclosed org-item-beginning-re end t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2030 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2031 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2032 (setq ltype (cond ((looking-at-p "^[ \t]*[0-9]") 'ordered) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2033 ((org-at-item-description-p) 'descriptive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2034 (t 'unordered)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2035 (let* ((indent1 (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2036 (nextitem (or (org-get-next-item (point) end) end)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2037 (item (org-trim (buffer-substring (point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2038 (org-end-of-item-or-at-child end)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2039 (nextindent (if (= (point) end) 0 (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2040 (item (if (string-match |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2041 "^\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\([xX ]\\)\\]" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2042 item) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2043 (replace-match (if (equal (match-string 1 item) " ") |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2044 "CBOFF" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2045 "CBON") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2046 t nil item 1) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2047 item))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2048 (push item output) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2049 (when (> nextindent indent1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2050 (save-restriction |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2051 (narrow-to-region (point) nextitem) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2052 (push (org-list-parse-list) output))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2053 (when delete |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2054 (delete-region start end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2055 (save-match-data |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2056 (when (and (not (eq org-list-ending-method 'indent)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2057 (looking-at (org-list-end-re))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2058 (replace-match "\n")))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2059 (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
|
2060 (push ltype output))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2061 |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2062 (defun org-list-make-subtree () |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2063 "Convert the plain list at point into a subtree." |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2064 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2065 (if (not (org-in-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2066 (error "Not in a list") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2067 (let ((list (org-list-parse-list t)) nstars) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2068 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2069 (if (ignore-errors |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2070 (org-back-to-heading)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2071 (progn (looking-at org-complex-heading-regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2072 (setq nstars (length (match-string 1)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2073 (setq nstars 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2074 (org-list-make-subtrees list (1+ nstars))))) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2075 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2076 (defun org-list-make-subtrees (list level) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2077 "Convert LIST into subtrees starting at LEVEL." |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2078 (if (symbolp (car list)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2079 (org-list-make-subtrees (cdr list) level) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2080 (mapcar (lambda (item) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2081 (if (stringp item) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2082 (insert (make-string |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2083 (if org-odd-levels-only |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2084 (1- (* 2 level)) level) ?*) " " item "\n") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2085 (org-list-make-subtrees item (1+ level)))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2086 list))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2087 |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2088 (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
|
2089 "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
|
2090 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2091 (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
|
2092 (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
|
2093 name pos) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2094 (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
|
2095 (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
|
2096 (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
|
2097 (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
|
2098 (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
|
2099 (setq pos (point)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2100 (insert txt) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2101 (goto-char pos))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2102 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2103 (defun org-list-send-list (&optional maybe) |
105973
b7d8222914b4
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
105341
diff
changeset
|
2104 "Send a transformed version of this list to the receiver position. |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2105 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
|
2106 this list." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2107 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2108 (catch 'exit |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2109 (unless (org-at-item-p) (error "Not at a list item")) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2110 (save-excursion |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2111 (re-search-backward "#\\+ORGLST" nil t) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2112 (unless (looking-at "[ \t]*#\\+ORGLST[: \t][ \t]*SEND[ \t]+\\([^ \t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?") |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2113 (if maybe |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2114 (throw 'exit nil) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2115 (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
|
2116 (let* ((name (match-string 1)) |
105973
b7d8222914b4
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
105341
diff
changeset
|
2117 (transform (intern (match-string 2))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2118 (bottom-point |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2119 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2120 (re-search-forward |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2121 "\\(\\\\end{comment}\\|@end ignore\\|-->\\)" nil t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2122 (match-beginning 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2123 (top-point |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2124 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2125 (re-search-backward "#\\+ORGLST" nil t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2126 (re-search-forward org-item-beginning-re bottom-point t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2127 (match-beginning 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2128 (list (save-restriction |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2129 (narrow-to-region top-point bottom-point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2130 (org-list-parse-list))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2131 beg txt) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2132 (unless (fboundp transform) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2133 (error "No such transformation function %s" transform)) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2134 (let ((txt (funcall transform list))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2135 ;; Find the insertion place |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2136 (save-excursion |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2137 (goto-char (point-min)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2138 (unless (re-search-forward |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2139 (concat "BEGIN RECEIVE ORGLST +" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2140 name |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2141 "\\([ \t]\\|$\\)") nil t) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2142 (error "Don't know where to insert translated list")) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2143 (goto-char (match-beginning 0)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2144 (beginning-of-line 2) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2145 (setq beg (point)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2146 (unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2147 (error "Cannot find end of insertion region")) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2148 (delete-region beg (point-at-bol)) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2149 (goto-char beg) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2150 (insert txt "\n"))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2151 (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
|
2152 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2153 (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
|
2154 "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
|
2155 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
|
2156 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2157 :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
|
2158 :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
|
2159 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2160 :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
|
2161 :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
|
2162 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2163 :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
|
2164 :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
|
2165 :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
|
2166 :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
|
2167 :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
|
2168 :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
|
2169 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2170 :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
|
2171 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
|
2172 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2173 :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
|
2174 :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
|
2175 :isep String to separate items |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2176 :lsep String to separate sublists |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2177 |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2178 :cboff String to insert for an unchecked checkbox |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2179 :cbon String to insert for a checked checkbox" |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2180 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2181 (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
|
2182 (splicep (plist-get p :splice)) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2183 (ostart (plist-get p :ostart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2184 (oend (plist-get p :oend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2185 (ustart (plist-get p :ustart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2186 (uend (plist-get p :uend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2187 (dstart (plist-get p :dstart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2188 (dend (plist-get p :dend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2189 (dtstart (plist-get p :dtstart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2190 (dtend (plist-get p :dtend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2191 (ddstart (plist-get p :ddstart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2192 (ddend (plist-get p :ddend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2193 (istart (plist-get p :istart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2194 (iend (plist-get p :iend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2195 (isep (plist-get p :isep)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2196 (lsep (plist-get p :lsep)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2197 (cbon (plist-get p :cbon)) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2198 (cboff (plist-get p :cboff))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2199 (let ((wrapper |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2200 (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
|
2201 (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
|
2202 ((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
|
2203 (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
|
2204 ((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
|
2205 (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
|
2206 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
|
2207 (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
|
2208 (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
|
2209 ((stringp sublist) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2210 (when (string-match "^\\(.*\\)[ \t]+::" sublist) |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2211 (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
|
2212 (match-string 1 sublist)))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2213 (setq sublist (concat ddstart |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2214 (org-trim (substring sublist |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2215 (match-end 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2216 ddend))) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2217 (if (string-match "\\[CBON\\]" sublist) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2218 (setq sublist (replace-match cbon t t sublist))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2219 (if (string-match "\\[CBOFF\\]" sublist) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2220 (setq sublist (replace-match cboff t t sublist))) |
105973
b7d8222914b4
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
105341
diff
changeset
|
2221 (if (string-match "\\[-\\]" sublist) |
b7d8222914b4
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
105341
diff
changeset
|
2222 (setq sublist (replace-match "$\\boxminus$" t t sublist))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2223 (setq rtn (concat rtn istart term sublist iend isep))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2224 (t (setq rtn (concat rtn ;; previous list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2225 lsep ;; list separator |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2226 (org-list-to-generic sublist p) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2227 lsep ;; list separator |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2228 ))))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2229 (format wrapper rtn)))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2230 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2231 (defun org-list-to-latex (list &optional params) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2232 "Convert LIST into a LaTeX list. |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2233 LIST is as returned by `org-list-parse-list'. PARAMS is a property list |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2234 with overruling parameters for `org-list-to-generic'." |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2235 (org-list-to-generic |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2236 list |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2237 (org-combine-plists |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2238 '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2239 :ustart "\\begin{itemize}" :uend "\\end{itemize}" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2240 :dstart "\\begin{description}" :dend "\\end{description}" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2241 :dtstart "[" :dtend "]" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2242 :ddstart "" :ddend "" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2243 :istart "\\item " :iend "" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2244 :isep "\n" :lsep "\n" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2245 :cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}") |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2246 params))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2247 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2248 (defun org-list-to-html (list &optional params) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2249 "Convert LIST into a HTML list. |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2250 LIST is as returned by `org-list-parse-list'. PARAMS is a property list |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2251 with overruling parameters for `org-list-to-generic'." |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2252 (org-list-to-generic |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2253 list |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2254 (org-combine-plists |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2255 '(:splicep nil :ostart "<ol>" :oend "</ol>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2256 :ustart "<ul>" :uend "</ul>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2257 :dstart "<dl>" :dend "</dl>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2258 :dtstart "<dt>" :dtend "</dt>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2259 :ddstart "<dd>" :ddend "</dd>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2260 :istart "<li>" :iend "</li>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2261 :isep "\n" :lsep "\n" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2262 :cbon "<code>[X]</code>" :cboff "<code>[ ]</code>") |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2263 params))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2264 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2265 (defun org-list-to-texinfo (list &optional params) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2266 "Convert LIST into a Texinfo list. |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2267 LIST is as returned by `org-list-parse-list'. PARAMS is a property list |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2268 with overruling parameters for `org-list-to-generic'." |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2269 (org-list-to-generic |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2270 list |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2271 (org-combine-plists |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2272 '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2273 :ustart "@enumerate" :uend "@end enumerate" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2274 :dstart "@table" :dend "@end table" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2275 :dtstart "@item " :dtend "\n" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2276 :ddstart "" :ddend "" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2277 :istart "@item\n" :iend "" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2278 :isep "\n" :lsep "\n" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2279 :cbon "@code{[X]}" :cboff "@code{[ ]}") |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2280 params))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2281 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2282 (provide 'org-list) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2283 |
98696 | 2284 ;; 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
|
2285 ;;; org-list.el ends here |