Mercurial > emacs
annotate lisp/org/org-list.el @ 112407:3c76e72abd5d
Update configure
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 22 Jan 2011 11:46:10 +0900 |
parents | ef719132ddfa |
children |
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 ;; |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
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 |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
10 ;; Version: 7.4 |
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 |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
465 (let ((ind (+ (or (get-text-property (point) 'original-indentation) 0) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
466 (org-get-indentation)))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
467 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
468 ((looking-at "^[ \t]*:END:") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
469 (throw 'exit item-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
470 ((<= (point) limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
471 (throw 'exit |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
472 (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
|
473 (point-at-bol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
474 item-ref))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
475 ((looking-at "^[ \t]*$") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
476 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
477 (beginning-of-line)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
478 ((looking-at "^[ \t]*#\\+end_") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
479 (re-search-backward "^[ \t]*#\\+begin_")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
480 ((not (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
481 (setq ind-ref (min ind ind-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
482 (forward-line -1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
483 ((>= ind ind-ref) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
484 (throw 'exit item-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
485 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
486 (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
|
487 (forward-line -1)))))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
488 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
489 (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
|
490 "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
|
491 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
|
492 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
493 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
|
494 `org-list-ending-method' for more information." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
495 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
496 (let ((ind-ref (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
497 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
498 (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
499 (case-fold-search t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
500 ;; do not start inside a block |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
501 (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
|
502 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
503 (catch 'exit |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
504 (while t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
505 (skip-chars-forward " \t") |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
506 (let ((ind (+ (or (get-text-property (point) 'original-indentation) 0) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
507 (org-get-indentation)))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
508 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
509 ((or (>= (point) limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
510 (looking-at ":END:")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
511 (throw 'exit (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
512 ;; Ensure bottom is just after a |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
513 ;; non-blank line. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
514 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
515 (min (point-max) (1+ (point-at-eol)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
516 ((= (point) (point-at-eol)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
517 (skip-chars-forward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
518 (beginning-of-line)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
519 ((org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
520 (setq ind-ref ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
521 (forward-line 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
522 ((<= ind ind-ref) |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
523 (throw 'exit (progn |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
524 ;; Again, ensure bottom is just after a |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
525 ;; non-blank line. |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
526 (skip-chars-backward " \r\t\n") |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
527 (min (point-max) (1+ (point-at-eol)))))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
528 ((looking-at "#\\+begin_") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
529 (re-search-forward "[ \t]*#\\+end_") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
530 (forward-line 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
531 (t (forward-line 1))))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
532 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
533 (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
|
534 "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
|
535 (and (org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
536 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
537 (goto-char (match-end 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
538 ;; Ignore counter if any |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
539 (when (looking-at "\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
540 (goto-char (match-end 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
541 (looking-at regexp)))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
542 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
543 (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
|
544 "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
|
545 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
|
546 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
|
547 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
548 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
549 (let* ((start (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
550 (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
|
551 ;; 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
|
552 (funcall pre-move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
553 ;; Skip any sublist on the way |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
554 (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
|
555 (> (org-get-indentation) ind))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
556 (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
|
557 (= (org-get-indentation) ind)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
558 (point-at-bol))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
559 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
560 (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
|
561 "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
|
562 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
|
563 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
564 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
|
565 list ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
566 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
567 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
|
568 some heuristics to guess the result." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
569 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
570 (let ((insert-blank-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
571 (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
|
572 usr-blank) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
573 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
574 ;; Trivial cases where there should be none. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
575 ((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
|
576 org-empty-line-terminates-plain-lists) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
577 (not insert-blank-p)) 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
578 ;; 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
|
579 ((eq insert-blank-p t) 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
580 ;; 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
|
581 ;; neighbours items in list. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
582 (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
|
583 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
584 ;; Is there a next item? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
585 (next-p (goto-char next-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
586 (org-back-over-empty-lines)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
587 ;; Is there a previous item? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
588 ((org-get-previous-item (point) top) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
589 (org-back-over-empty-lines)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
590 ;; User inserted blank lines, trust him |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
591 ((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
|
592 (> (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
593 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
594 (skip-chars-backward " \t") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
595 (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
|
596 usr-blank) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
597 ;; Are there blank lines inside the item ? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
598 ((save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
599 (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
600 "^[ \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
|
601 ;; No parent: no blank line. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
602 (t 0)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
603 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
604 (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
|
605 "Insert a new list item at POS. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
606 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
|
607 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
|
608 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
609 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
|
610 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
|
611 function ends." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
612 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
613 ;; Is point in a special block? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
614 (when (org-in-regexps-block-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
615 "^[ \t]*#\\+\\(begin\\|BEGIN\\)_\\([a-zA-Z0-9_]+\\)" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
616 '(concat "^[ \t]*#\\+\\(end\\|END\\)_" (match-string 2))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
617 (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
|
618 ;; 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
|
619 (error "Cannot insert item inside a block") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
620 ;; 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
|
621 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
622 (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
|
623 (end-of-line 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
624 (let* ((true-pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
625 (top (org-list-top-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
626 (bottom (copy-marker (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
627 (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
|
628 (org-list-bullet-string (org-get-bullet)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
629 (ind (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
630 (before-p (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
631 ;; Description item: text starts after colons. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
632 (or (org-at-item-description-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
633 ;; At a checkbox: text starts after it. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
634 (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
635 ;; Otherwise, text starts after bullet. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
636 (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
637 (<= true-pos (match-end 0)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
638 (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
|
639 true-pos top bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
640 (insert-fun |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
641 (lambda (text) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
642 ;; 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
|
643 ;; with possible blank lines ending last item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
644 (goto-char (org-get-item-beginning)) |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
645 (org-indent-to-column ind) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
646 (insert (concat bullet (when checkbox "[ ] ") after-bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
647 ;; Stay between after-bullet and before text. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
648 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
649 (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
|
650 (unless before-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
651 ;; 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
|
652 ;; bottom point but will modify marker anyway |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
653 (setq bottom (marker-position bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
654 (let ((col (current-column))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
655 (org-list-exchange-items |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
656 (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
|
657 bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
658 ;; recompute next-item: last sexp modified list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
659 (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
|
660 (org-move-to-column col))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
661 ;; 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
|
662 ;; marker here |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
663 (setq bottom (copy-marker bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
664 (when checkbox (org-update-checkbox-count-maybe)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
665 (org-list-repair nil top bottom)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
666 (goto-char true-pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
667 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
668 (before-p (funcall insert-fun nil) t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
669 ;; 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
|
670 ((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
|
671 (funcall insert-fun nil) t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
672 ;; 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
|
673 ;; 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
|
674 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
675 (delete-horizontal-space) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
676 ;; 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
|
677 (let* ((pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
678 (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
|
679 (after-text |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
680 (when (< pos end-before-blank) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
681 (prog1 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
682 (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
|
683 ;; 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
|
684 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
685 (while (looking-at "^[ \t]*$") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
686 (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
|
687 (beginning-of-line 0)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
688 (funcall insert-fun after-text) t))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
689 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
690 (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
|
691 (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
|
692 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
693 (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
|
694 "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
|
695 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
|
696 it will be indented. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
697 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
698 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
|
699 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
700 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
|
701 children. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
702 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
703 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
|
704 item ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
705 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
706 Return t if successful." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
707 (let* ((regionp (org-region-active-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
708 (rbeg (and regionp (region-beginning))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
709 (rend (and regionp (region-end)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
710 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
711 ((and regionp |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
712 (goto-char rbeg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
713 (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
|
714 (error "No item in region")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
715 ((not (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
716 (error "Not on an item")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
717 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
718 ;; 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
|
719 (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
|
720 (not no-subtree) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
721 (= top (point-at-bol))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
722 ;; 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
|
723 ;; 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
|
724 (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
|
725 (memq this-command '(org-shiftmetaright org-shiftmetaleft))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
726 (if regionp |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
727 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
728 (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
|
729 (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
|
730 (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
|
731 (set-marker org-last-indent-end-marker |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
732 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
733 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
734 (specialp bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
735 (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
|
736 (t (org-get-end-of-item bottom))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
737 ;; Get everything ready |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
738 (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
|
739 (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
|
740 (struct (org-list-struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
741 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
|
742 (origins (org-list-struct-origins struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
743 (beg-item (assq beg struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
744 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
745 ;; 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
|
746 (specialp |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
747 (let* ((level-skip (org-level-increment)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
748 (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
|
749 (top-ind (nth 1 beg-item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
750 (if (< (+ top-ind offset) 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
751 (error "Cannot outdent beyond margin") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
752 ;; Change bullet if necessary |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
753 (when (and (= (+ top-ind offset) 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
754 (string-match "*" (nth 2 beg-item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
755 (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
|
756 (org-list-bullet-string "-")))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
757 ;; Shift ancestor |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
758 (let ((anc (car struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
759 (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
|
760 (org-list-struct-fix-struct struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
761 (org-list-struct-apply-struct struct end)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
762 ;; Forbidden move |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
763 ((and (< arg 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
764 (or (and no-subtree |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
765 (not regionp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
766 (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
|
767 (let ((last-item (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
768 (goto-char end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
769 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
770 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
771 (org-list-struct-assoc-at-point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
772 (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
|
773 (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
|
774 ;; Normal shifting |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
775 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
776 (let* ((shifted-ori (if (< arg 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
777 (org-list-struct-outdent beg end origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
778 (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
|
779 (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
|
780 (org-list-struct-apply-struct struct bottom)))))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
781 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
782 ;;; Predicates |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
783 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
784 (defun org-in-item-p () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
785 "Is the cursor inside a plain list? |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
786 This checks `org-list-ending-method'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
787 (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
|
788 (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
|
789 (bound (if prev-head |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
790 (or (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
791 (let ((case-fold-search t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
792 (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
|
793 prev-head) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
794 (point-min)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
795 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
796 ((eq org-list-ending-method 'regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
797 (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
|
798 ((eq org-list-ending-method 'indent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
799 (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
|
800 (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
|
801 (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
|
802 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
803 (defun org-list-first-item-p (top) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
804 "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
|
805 Assume point is at an item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
806 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
807 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
|
808 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
809 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
810 (let ((ind (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
811 (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
|
812 (< (org-get-indentation) ind))))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
813 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
814 (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
|
815 "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
|
816 (save-excursion |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
817 (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
|
818 |
101568
f5aedb5cbd80
2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101515
diff
changeset
|
819 (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
|
820 "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
|
821 (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
|
822 (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
|
823 (< (point) (match-end 0)))) |
f5aedb5cbd80
2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101515
diff
changeset
|
824 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
825 (defun org-at-item-timer-p () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
826 "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
|
827 (org-list-at-regexp-after-bullet-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
828 "\\([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
|
829 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
830 (defun org-at-item-description-p () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
831 "Is point at a description list item?" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
832 (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
|
833 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
834 (defun org-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
|
835 "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
|
836 (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
|
837 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
838 (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
|
839 "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
|
840 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
|
841 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
842 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
|
843 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
|
844 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
|
845 (catch 'exit |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
846 (save-match-data |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
847 (save-excursion |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
848 (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
|
849 (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
|
850 ;; 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
|
851 (throw 'exit nil)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
852 (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
|
853 (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
|
854 (error (throw 'exit nil))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
855 (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
|
856 (when (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
857 "^[ \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
|
858 (org-current-line))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
859 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
860 ;;; Navigate |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
861 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
862 ;; 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
|
863 ;; 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
|
864 ;; 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
|
865 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
866 ;; 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
|
867 ;; 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
|
868 ;; `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
|
869 ;; 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
|
870 ;; 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
|
871 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
872 (defun org-list-top-point () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
873 "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
|
874 Assume point is in a list." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
875 (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
|
876 (bound (if prev-head |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
877 (or (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
878 (let ((case-fold-search t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
879 (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
|
880 prev-head) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
881 (point-min)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
882 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
883 ((eq org-list-ending-method 'regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
884 (org-list-top-point-with-regexp bound)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
885 ((eq org-list-ending-method 'indent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
886 (org-list-top-point-with-indent bound)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
887 (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
|
888 (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
|
889 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
890 (defun org-list-bottom-point () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
891 "Return point just before list ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
892 Assume point is in a list." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
893 (let* ((next-head (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
894 (and (let ((outline-regexp org-outline-regexp)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
895 ;; Use default regexp because folding |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
896 ;; changes OUTLINE-REGEXP. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
897 (outline-next-heading))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
898 (limit (or (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
899 (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
|
900 (point-at-bol))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
901 next-head |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
902 (point-max)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
903 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
904 ((eq org-list-ending-method 'regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
905 (org-list-bottom-point-with-regexp limit)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
906 ((eq org-list-ending-method 'indent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
907 (org-list-bottom-point-with-indent limit)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
908 (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
|
909 (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
|
910 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
911 (defun org-get-item-beginning () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
912 "Return position of current item beginning." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
913 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
914 ;; possibly match current line |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
915 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
916 (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
|
917 (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
|
918 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
919 (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
|
920 "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
|
921 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
|
922 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
923 (if (org-in-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
924 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
925 (error "Not in an item"))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
926 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
927 (defun org-get-beginning-of-list (top) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
928 "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
|
929 TOP is the position at list beginning." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
930 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
931 (let (prev-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
932 (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
|
933 (goto-char prev-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
934 (point-at-bol)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
935 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
936 (defun org-beginning-of-item-list () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
937 "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
|
938 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
|
939 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
940 (if (org-in-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
941 (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
|
942 (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
|
943 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
944 (defun org-get-end-of-list (bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
945 "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
|
946 BOTTOM is the position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
947 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
948 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
949 (let ((ind (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
950 (while (and (/= (point) bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
951 (>= (org-get-indentation) ind)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
952 (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
|
953 (if (= (point) bottom) bottom (point-at-bol))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
954 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
955 (defun org-end-of-item-list () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
956 "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
|
957 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
|
958 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
959 (if (org-in-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
960 (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
|
961 (error "Not in an item"))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
962 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
963 (defun org-get-end-of-item (bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
964 "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
|
965 BOTTOM is the position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
966 (or (org-get-next-item (point) bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
967 (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
|
968 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
969 (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
|
970 "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
|
971 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
|
972 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
973 (if (org-in-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
974 (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
|
975 (error "Not in an item"))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
976 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
977 (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
|
978 "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
|
979 BOTTOM is the position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
980 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
981 (goto-char |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
982 (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
|
983 (point-at-bol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
984 (org-get-end-of-item bottom)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
985 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
986 (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
|
987 "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
|
988 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
|
989 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
990 BOTTOM is the position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
991 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
992 (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
|
993 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
994 (point-at-eol))) |
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-get-previous-item (pos limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
997 "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
|
998 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
|
999 (org-list-get-item-same-level |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1000 #'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
|
1001 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1002 (defun org-previous-item () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1003 "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
|
1004 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
|
1005 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
|
1006 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1007 (if (not (org-in-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1008 (error "Not in an item") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1009 (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
|
1010 (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
|
1011 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1012 (defun org-get-next-item (pos limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1013 "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
|
1014 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
|
1015 (org-list-get-item-same-level |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1016 #'org-search-forward-unenclosed pos limit #'end-of-line)) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1017 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1018 (defun org-next-item () |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1019 "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
|
1020 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
|
1021 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
|
1022 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1023 (if (not (org-in-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1024 (error "Not in an item") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1025 (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
|
1026 (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
|
1027 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1028 ;;; Manipulate |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1029 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1030 (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
|
1031 "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
|
1032 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
|
1033 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
|
1034 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1035 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
|
1036 (save-excursion |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1037 (let* ((end-of-item-no-blank |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1038 (lambda (pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1039 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1040 (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
|
1041 (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
|
1042 (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
|
1043 (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
|
1044 (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
|
1045 (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
|
1046 (goto-char beg-A) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1047 (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
|
1048 (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
|
1049 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1050 (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
|
1051 "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
|
1052 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
|
1053 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
|
1054 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1055 (if (not (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1056 (error "Not at an item") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1057 (let* ((pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1058 (col (current-column)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1059 (bottom (org-list-bottom-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1060 (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
|
1061 (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
|
1062 (if (not next-item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1063 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1064 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1065 (error "Cannot move this item further down")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1066 (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
|
1067 (org-list-repair nil nil bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1068 (goto-char (org-get-next-item (point) bottom)) |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1069 (org-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
|
1070 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1071 (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
|
1072 "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
|
1073 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
|
1074 so this really moves item trees." |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1075 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1076 (if (not (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1077 (error "Not at an item") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1078 (let* ((pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1079 (col (current-column)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1080 (top (org-list-top-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1081 (bottom (org-list-bottom-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1082 (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
|
1083 (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
|
1084 (if (not prev-item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1085 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1086 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1087 (error "Cannot move this item further up")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1088 (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
|
1089 (org-list-repair nil top bottom) |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1090 (org-move-to-column col))))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1091 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1092 (defun org-insert-item (&optional checkbox) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1093 "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
|
1094 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
|
1095 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
|
1096 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1097 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
|
1098 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1099 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
|
1100 item is invisible." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1101 (unless (or (not (org-in-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1102 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1103 (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1104 (org-invisible-p))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1105 (if (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1106 (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-timer-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1108 ;; Timer list: delegate to `org-timer-item'. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1109 (progn (org-timer-item) t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1110 ;; 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
|
1111 (let ((desc-text (when (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1112 (and (goto-char (org-get-item-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1113 (org-at-item-description-p))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1114 (concat (read-string "Term: ") " :: ")))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1115 ;; 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
|
1116 ;; is a description item. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1117 (org-list-insert-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1118 (point) (and checkbox |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1119 (or (not desc-text) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1120 (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
|
1121 desc-text))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1122 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1123 ;;; Structures |
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 ;; 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
|
1126 ;; 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
|
1127 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1128 ;; 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
|
1129 ;; 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
|
1130 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1131 ;; 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
|
1132 ;; 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
|
1133 ;; `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
|
1134 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1135 (defun org-list-struct-assoc-at-point () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1136 "Return the structure association at point. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1137 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
|
1138 bullet string and bullet counter, if any." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1139 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1140 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1141 (list (point-at-bol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1142 (org-get-indentation) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1143 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1144 (looking-at "^[ \t]*\\([-+*0-9.)]+[ \t]+\\)") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1145 (match-string 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1146 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1147 (goto-char (match-end 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1148 (and (looking-at "\\[@\\(?:start:\\)?\\([0-9]+\\)\\]") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1149 (match-string 1)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1150 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1151 (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
|
1152 "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
|
1153 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
|
1154 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
|
1155 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
|
1156 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
|
1157 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
|
1158 ancestor at position 0. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1159 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1160 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
|
1161 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
|
1162 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1163 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
|
1164 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
|
1165 change is an outdent." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1166 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1167 (let* (struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1168 (extend |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1169 (lambda (struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1170 (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
|
1171 (begin (caar struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1172 (end (caar (last struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1173 pre-list post-list) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1174 (goto-char begin) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1175 ;; 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
|
1176 (while (and (org-search-backward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1177 org-item-beginning-re top t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1178 (>= (org-get-indentation) ind-min)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1179 (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
|
1180 pre-list))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1181 ;; 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
|
1182 (if (< (org-get-indentation) ind-min) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1183 (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
|
1184 pre-list)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1185 (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
|
1186 pre-list))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1187 ;; Find end of min list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1188 (goto-char end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1189 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1190 (while (and (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1191 org-item-beginning-re bottom 'move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1192 (>= (org-get-indentation) ind-min)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1193 (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
|
1194 post-list))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1195 ;; 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
|
1196 ;; indented that top-item, add them anyhow. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1197 (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
|
1198 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1199 (while (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1200 org-item-beginning-re bottom t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1201 (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
|
1202 post-list)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1203 (append pre-list struct (reverse post-list)))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1204 ;; 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
|
1205 (goto-char end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1206 (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
|
1207 (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
|
1208 ;; ... 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
|
1209 (let ((extended (funcall extend struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1210 ;; ... 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
|
1211 ;; extended |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1212 (if (and outdent (> (caar extended) 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1213 (funcall extend extended) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1214 extended))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1215 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1216 (defun org-list-struct-origins (struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1217 "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
|
1218 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
|
1219 (let* ((struct-rev (reverse struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1220 (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
|
1221 (prev-item (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1222 (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
|
1223 (get-origins |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1224 (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1225 (let* ((item-pos (car item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1226 (ind (nth 1 item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1227 (prev-ind (caar acc))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1228 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1229 ;; List closing. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1230 ((> prev-ind ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1231 (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
|
1232 ;; needed if top-point is |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1233 ;; not the most outdented |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1234 (last acc)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1235 (setq acc current-origin) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1236 (cons item-pos (cdar acc)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1237 ;; New list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1238 ((< prev-ind ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1239 (let ((origin (funcall prev-item item-pos))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1240 (setq acc (cons (cons ind origin) acc)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1241 (cons item-pos origin))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1242 ;; Current list going on |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1243 (t (cons item-pos (cdar acc)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1244 (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
|
1245 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1246 (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
|
1247 "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
|
1248 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
|
1249 (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
|
1250 (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
|
1251 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1252 (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
|
1253 "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
|
1254 (let ((ind (nth 1 item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1255 (next-item (cadr (member item struct)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1256 (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
|
1257 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1258 (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
|
1259 "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
|
1260 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
|
1261 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1262 This function modifies STRUCT." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1263 (let* (acc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1264 (init-bul (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1265 (let ((counter (nth 3 item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1266 (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
|
1267 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1268 ((and (string-match "[0-9]+" bullet) counter) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1269 (replace-match counter nil nil bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1270 ((string-match "[0-9]+" bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1271 (replace-match "1" nil nil bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1272 (t bullet))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1273 (set-bul (lambda (item bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1274 (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
|
1275 (get-bul (lambda (item bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1276 (let* ((counter (nth 3 item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1277 (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
|
1278 (replace-match counter nil nil bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1279 bullet)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1280 (fix-bul |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1281 (lambda (item) struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1282 (let* ((parent (cdr (assq (car item) origins))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1283 (orig-ref (assq parent acc))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1284 (if orig-ref |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1285 ;; Continuing previous list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1286 (let* ((prev-bul (cdr orig-ref)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1287 (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
|
1288 (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
|
1289 (funcall set-bul item new-bul)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1290 ;; A new list is starting |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1291 (let ((new-bul (funcall init-bul item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1292 (funcall set-bul item new-bul) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1293 (setq acc (cons (cons parent |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1294 (org-list-inc-bullet-maybe new-bul)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1295 acc)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1296 (mapc fix-bul (cdr struct)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1297 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1298 (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
|
1299 "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
|
1300 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
|
1301 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1302 This function modifies STRUCT." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1303 (let* ((headless (cdr struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1304 (ancestor (car struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1305 (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
|
1306 (new-ind |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1307 (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1308 (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
|
1309 (if parent |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1310 ;; 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
|
1311 (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
|
1312 (cddr item))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1313 ;; If no parent, indent like top-point |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1314 (setcdr item (cons top-ind (cddr item)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1315 (mapc new-ind headless))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1316 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1317 (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
|
1318 "Return STRUCT with correct bullets and indentation. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1319 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
|
1320 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1321 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
|
1322 (let ((old (copy-alist struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1323 (org-list-struct-fix-bul struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1324 (org-list-struct-fix-ind struct origins) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1325 (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
|
1326 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1327 (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
|
1328 "Outdent items in a structure. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1329 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
|
1330 END, excluded. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1331 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1332 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
|
1333 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1334 STRUCT is the concerned structure." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1335 (let* (acc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1336 (out (lambda (cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1337 (let* ((item (car cell)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1338 (parent (cdr cell))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1339 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1340 ;; Item not yet in zone: keep association |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1341 ((< item start) cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1342 ;; 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
|
1343 ((>= item end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1344 (let ((convert (assq parent acc))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1345 (if convert (cons item (cdr convert)) cell))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1346 ;; Item has no parent: error |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1347 ((<= parent 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1348 (error "Cannot outdent top-level items")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1349 ;; Parent is outdented: keep association |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1350 ((>= parent start) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1351 (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
|
1352 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1353 ;; 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
|
1354 (let ((grand-parent (cdr (assq parent origins)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1355 (setq acc (cons (cons parent item) acc)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1356 (cons item grand-parent)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1357 (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
|
1358 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1359 (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
|
1360 "Indent items in a structure. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1361 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
|
1362 END, excluded. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1363 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1364 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
|
1365 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1366 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
|
1367 `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
|
1368 END." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1369 (let* (acc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1370 (orig-rev (reverse origins)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1371 (get-prev-item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1372 (lambda (cell parent) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1373 (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
|
1374 (set-assoc |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1375 (lambda (cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1376 (setq acc (cons cell acc)) cell)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1377 (change-bullet-maybe |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1378 (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1379 (let* ((full-item (assq item struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1380 (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
|
1381 (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
|
1382 (when new-bul-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1383 ;; 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
|
1384 ;; will be modified |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1385 (setcdr full-item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1386 (list (nth 1 full-item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1387 new-bul-p |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1388 (nth 3 full-item))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1389 (ind |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1390 (lambda (cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1391 (let* ((item (car cell)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1392 (parent (cdr cell))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1393 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1394 ;; Item not yet in zone: keep association |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1395 ((< item start) cell) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1396 ((>= item end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1397 ;; 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
|
1398 (let ((convert (assq parent acc))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1399 (if convert (cons item (cdr convert)) cell))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1400 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1401 ;; Item is in zone... |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1402 (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
|
1403 ;; Check if bullet needs to be changed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1404 (funcall change-bullet-maybe item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1405 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1406 ;; First item indented but not parent: error |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1407 ((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
|
1408 (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
|
1409 ;; 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
|
1410 ((or (not prev) (= prev 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1411 (funcall set-assoc cell)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1412 ;; Previous item not indented: reparent to it |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1413 ((< prev start) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1414 (funcall set-assoc (cons item prev))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1415 ;; Previous item indented: reparent like it |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1416 (t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1417 (funcall set-assoc (cons item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1418 (cdr (assq prev acc))))))))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1419 (mapcar ind origins))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1420 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1421 (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
|
1422 "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
|
1423 BOTTOM is position at list ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1424 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1425 Initial position is restored after the changes." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1426 (let* ((pos (copy-marker (point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1427 (ancestor (caar struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1428 (modify |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1429 (lambda (item) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1430 (goto-char (car item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1431 (let* ((new-ind (nth 1 item)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1432 (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
|
1433 (old-ind (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1434 (old-bul (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1435 (looking-at "[ \t]*\\(\\S-+[ \t]*\\)") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1436 (match-string 1))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1437 (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
|
1438 (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
|
1439 ;; 1. Shift item's body |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1440 (unless (= old-body-ind new-body-ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1441 (org-shift-item-indentation |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1442 (- new-body-ind old-body-ind) bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1443 ;; 2. Replace bullet |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1444 (unless (equal new-bul old-bul) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1445 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1446 (looking-at "[ \t]*\\(\\S-+[ \t]*\\)") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1447 (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
|
1448 ;; 3. Indent item to appropriate column |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1449 (unless (= new-ind old-ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1450 (delete-region (point-at-bol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1451 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1452 (skip-chars-forward " \t") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1453 (point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1454 (indent-to new-ind))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1455 ;; Remove ancestor if it is left. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1456 (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
|
1457 (cdr struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1458 struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1459 ;; Apply changes from bottom to top |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1460 (mapc modify (nreverse struct-to-apply)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1461 (goto-char pos))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1462 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1463 ;;; Indentation |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1464 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1465 (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
|
1466 "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
|
1467 (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
|
1468 (catch 'exit |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1469 (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
|
1470 (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
|
1471 (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
|
1472 ((= 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
|
1473 (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
|
1474 i)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1475 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1476 (defun org-shift-item-indentation (delta bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1477 "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
|
1478 Sub-items are not moved. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1479 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1480 BOTTOM is position at list ending." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1481 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1482 (let ((beg (point-at-bol)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1483 (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
|
1484 (beginning-of-line (unless (eolp) 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1485 (while (> (point) beg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1486 (when (looking-at "[ \t]*\\S-") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1487 ;; this is not an empty line |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1488 (let ((i (org-get-indentation))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1489 (when (and (> i 0) (> (+ i delta) 0)) |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1490 (org-indent-line-to (+ i delta))))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1491 (beginning-of-line 0))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1492 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1493 (defun org-outdent-item () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1494 "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
|
1495 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
|
1496 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1497 (org-list-indent-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1498 -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
|
1499 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1500 (defun org-indent-item () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1501 "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
|
1502 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
|
1503 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1504 (org-list-indent-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1505 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
|
1506 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1507 (defun org-outdent-item-tree () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1508 "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
|
1509 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
|
1510 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1511 (org-list-indent-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1512 -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
|
1513 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1514 (defun org-indent-item-tree () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1515 "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
|
1516 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
|
1517 (interactive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1518 (org-list-indent-item-generic |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1519 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
|
1520 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1521 (defvar org-tab-ind-state) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1522 (defun org-cycle-item-indentation () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1523 "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
|
1524 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
|
1525 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
|
1526 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
|
1527 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1528 Return t at each successful move." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1529 (let ((org-adapt-indentation nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1530 (ind (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1531 (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
|
1532 (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
|
1533 (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1534 (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1535 ;; Check that item is really empty |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1536 (>= (match-end 0) (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1537 (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
|
1538 (skip-chars-backward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1539 (point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1540 (setq this-command 'org-cycle-item-indentation) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1541 (let ((top (org-list-top-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1542 ;; 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
|
1543 ;; 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
|
1544 ;; go back to original position. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1545 (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
|
1546 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1547 ((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
|
1548 ((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
|
1549 (ignore-errors |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1550 (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
|
1551 (t (back-to-indentation) |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1552 (org-indent-to-column (car org-tab-ind-state)) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1553 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1554 (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
|
1555 ;; Break cycle |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1556 (setq this-command 'identity))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1557 ;; 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
|
1558 ;; 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
|
1559 (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
|
1560 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1561 ((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
|
1562 ((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
|
1563 (t (error "Cannot move item"))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1564 t))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1565 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1566 ;;; Bullets |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1567 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1568 (defun org-get-bullet () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1569 "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
|
1570 Assume cursor is at an item." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1571 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1572 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1573 (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
|
1574 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1575 (defun org-list-bullet-string (bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1576 "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
|
1577 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
|
1578 `org-list-two-spaces-after-bullet-regexp'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1579 (save-match-data |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1580 (string-match "\\S-+\\([ \t]*\\)" bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1581 (replace-match |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1582 (save-match-data |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1583 (concat |
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 ;; 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
|
1586 (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
|
1587 (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
|
1588 " "))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1589 nil nil bullet 1))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1590 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1591 (defun org-list-inc-bullet-maybe (bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1592 "Increment BULLET if applicable." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1593 (if (string-match "[0-9]+" bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1594 (replace-match |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1595 (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
|
1596 nil nil bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1597 bullet)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1598 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1599 (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
|
1600 "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
|
1601 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
|
1602 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1603 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
|
1604 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
|
1605 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1606 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
|
1607 list beginning and list ending. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1608 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1609 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
|
1610 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1611 (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
|
1612 (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
|
1613 (struct (org-list-struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1614 (point-at-bol) (point-at-eol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1615 (or top (org-list-top-point)) bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1616 (origins (org-list-struct-origins struct)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1617 fixed-struct) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1618 (if (stringp force-bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1619 (let ((begin (nth 1 struct))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1620 (setcdr begin (list (nth 1 begin) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1621 (org-list-bullet-string force-bullet) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1622 (nth 3 begin))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1623 (setq fixed-struct |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1624 (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
|
1625 (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
|
1626 (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
|
1627 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1628 (defun org-cycle-list-bullet (&optional which) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1629 "Cycle through the different itemize/enumerate bullets. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1630 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
|
1631 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1632 `-' -> `+' -> `*' -> `1.' -> `1)' |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1633 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1634 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
|
1635 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
|
1636 'previous, cycle backwards." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1637 (interactive "P") |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1638 (save-excursion |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1639 (let* ((top (org-list-top-point)) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1640 (bullet (progn |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1641 (goto-char (org-get-beginning-of-list top)) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1642 (org-get-bullet))) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1643 (current (cond |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1644 ((string-match "\\." bullet) "1.") |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1645 ((string-match ")" bullet) "1)") |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1646 (t bullet))) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1647 (bullet-rule-p (cdr (assq 'bullet org-list-automatic-rules))) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1648 (bullet-list (append '("-" "+" ) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1649 ;; *-bullets are not allowed at column 0 |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1650 (unless (and bullet-rule-p |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1651 (looking-at "\\S-")) '("*")) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1652 ;; Description items cannot be numbered |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1653 (unless (and bullet-rule-p |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1654 (or (eq org-plain-list-ordered-item-terminator ?\)) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1655 (org-at-item-description-p))) '("1.")) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1656 (unless (and bullet-rule-p |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1657 (or (eq org-plain-list-ordered-item-terminator ?.) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1658 (org-at-item-description-p))) '("1)")))) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1659 (len (length bullet-list)) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1660 (item-index (- len (length (member current bullet-list)))) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1661 (get-value (lambda (index) (nth (mod index len) bullet-list))) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1662 (new (cond |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1663 ((member which bullet-list) which) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1664 ((numberp which) (funcall get-value which)) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1665 ((eq 'previous which) (funcall get-value (1- item-index))) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1666 (t (funcall get-value (1+ item-index)))))) |
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
1667 (org-list-repair new top)))) |
111506
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 ;;; Checkboxes |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1670 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1671 (defun org-toggle-checkbox (&optional toggle-presence) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1672 "Toggle the checkbox in the current line. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1673 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
|
1674 double prefix, set checkbox to [-]. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1675 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1676 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
|
1677 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
|
1678 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
|
1679 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1680 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
|
1681 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
|
1682 in subtree, ignoring drawers." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1683 (interactive "P") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1684 ;; 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
|
1685 ;; 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
|
1686 ;; toggles on single items will return errors. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1687 (let* ((bounds |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1688 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1689 ((org-region-active-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1690 (let ((rbeg (region-beginning)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1691 (rend (region-end))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1692 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1693 (goto-char rbeg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1694 (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
|
1695 (list (point-at-bol) rend nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1696 (error "No item in region"))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1697 ((org-on-heading-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1698 ;; 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
|
1699 ;; subtree outside drawers |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1700 (let ((pos (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1701 (limit (save-excursion (outline-next-heading) (point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1702 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1703 (goto-char limit) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1704 (org-search-backward-unenclosed ":END:" pos 'move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1705 (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1706 org-item-beginning-re limit 'move) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1707 (list (point) limit nil)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1708 ((org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1709 (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
|
1710 (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
|
1711 (beg (car bounds)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1712 ;; 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
|
1713 ;; will change bottom point |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1714 (end (copy-marker (nth 1 bounds))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1715 (single-p (nth 2 bounds)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1716 (ref-presence (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1717 (goto-char beg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1718 (org-at-item-checkbox-p))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1719 (ref-status (equal (match-string 1) "[X]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1720 (act-on-item |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1721 (lambda (ref-pres ref-stat) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1722 (if (equal toggle-presence '(4)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1723 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1724 ((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
|
1725 (replace-match "")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1726 ((and (not ref-pres) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1727 (not (org-at-item-checkbox-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1728 (org-at-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1729 (goto-char (match-end 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1730 ;; Ignore counter, if any |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1731 (when (looking-at "\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1732 (goto-char (match-end 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1733 (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
|
1734 (cdr (assq 'checkbox org-list-automatic-rules))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1735 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1736 ((and single-p desc-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1737 (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
|
1738 ((not desc-p) (insert "[ ] ")))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1739 (let ((blocked (org-checkbox-blocked-p))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1740 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1741 ((and blocked single-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1742 (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
|
1743 (blocked nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1744 ((org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1745 (replace-match |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1746 (cond ((equal toggle-presence '(16)) "[-]") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1747 (ref-stat "[ ]") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1748 (t "[X]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1749 t t nil 1)))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1750 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1751 (goto-char beg) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1752 (while (< (point) end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1753 (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
|
1754 (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
|
1755 (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
|
1756 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1757 (defun org-reset-checkbox-state-subtree () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1758 "Reset all checkboxes in an entry subtree." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1759 (interactive "*") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1760 (save-restriction |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1761 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1762 (org-narrow-to-subtree) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1763 (org-show-subtree) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1764 (goto-char (point-min)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1765 (let ((end (point-max))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1766 (while (< (point) end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1767 (when (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1768 (replace-match "[ ]" t t nil 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1769 (beginning-of-line 2)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1770 (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
|
1771 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1772 (defvar org-checkbox-statistics-hook nil |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1773 "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
|
1774 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
|
1775 `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
|
1776 implement alternative ways of collecting statistics |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1777 information.") |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1778 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1779 (defun org-update-checkbox-count-maybe () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1780 "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
|
1781 (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
|
1782 (org-update-checkbox-count)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1783 (run-hooks 'org-checkbox-statistics-hook)) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1784 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1785 (defun org-update-checkbox-count (&optional all) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1786 "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
|
1787 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
|
1788 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
|
1789 the whole buffer." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1790 (interactive "P") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1791 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1792 (let ((cstat 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1793 (catch 'exit |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1794 (while t |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1795 (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
|
1796 (beg (condition-case nil |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1797 (progn (org-back-to-heading) (point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1798 (error (point-min)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1799 (end (copy-marker (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1800 (outline-next-heading) (point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1801 (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
|
1802 (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
|
1803 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
|
1804 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
|
1805 (recursive |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1806 (or (not org-hierarchical-checkbox-statistics) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1807 (string-match "\\<recursive\\>" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1808 (or (ignore-errors |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1809 (org-entry-get nil "COOKIE_DATA")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1810 ""))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1811 (goto-char end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1812 ;; find each statistics cookie |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1813 (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
|
1814 (not (save-match-data |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1815 (and (org-on-heading-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1816 (string-match "\\<todo\\>" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1817 (downcase |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1818 (or (org-entry-get |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1819 nil "COOKIE_DATA") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1820 ""))))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1821 (setq beg-cookie (match-beginning 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1822 end-cookie (match-end 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1823 cstat (+ cstat (if end-cookie 1 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1824 startsearch (point-at-eol) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1825 continue-from (match-beginning 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1826 is-percent (match-beginning 2) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1827 lim (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1828 ((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
|
1829 ;; 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
|
1830 ;; computing list boundaries as many times. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1831 ((org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1832 (unless (and list-beg (>= (point) list-beg)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1833 (setq list-beg (org-list-top-point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1834 list-end (copy-marker |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1835 (org-list-bottom-point)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1836 (org-get-end-of-item list-end)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1837 (t nil)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1838 c-on 0 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1839 c-off 0) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1840 (when lim |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1841 ;; 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
|
1842 ;; 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
|
1843 (goto-char startsearch) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1844 (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
|
1845 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1846 (beginning-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1847 (setq curr-ind (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1848 (setq next-ind curr-ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1849 (while (and (bolp) (org-at-item-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1850 (if recursive |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1851 (<= curr-ind next-ind) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1852 (= curr-ind next-ind))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1853 (when (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1854 (if (member (match-string 1) '("[ ]" "[-]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1855 (setq c-off (1+ c-off)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1856 (setq c-on (1+ c-on)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1857 (if (not recursive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1858 ;; 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
|
1859 ;; with proper limit. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1860 (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
|
1861 (end-of-line) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1862 (when (org-search-forward-unenclosed |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1863 org-item-beginning-re lim t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1864 (beginning-of-line))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1865 (setq next-ind (org-get-indentation))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1866 (goto-char continue-from) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1867 ;; update cookie |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1868 (when end-cookie |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1869 (setq new (if is-percent |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1870 (format "[%d%%]" (/ (* 100 c-on) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1871 (max 1 (+ c-on c-off)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1872 (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
|
1873 (goto-char beg-cookie) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1874 (insert new) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1875 (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
|
1876 ;; update items checkbox if it has one |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1877 (when (and (org-at-item-checkbox-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1878 (> (+ c-on c-off) 0)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1879 (setq beg-cookie (match-beginning 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1880 end-cookie (match-end 1)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1881 (delete-region beg-cookie end-cookie) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1882 (goto-char beg-cookie) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1883 (cond ((= c-off 0) (insert "[X]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1884 ((= c-on 0) (insert "[ ]")) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1885 (t (insert "[-]"))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1886 (goto-char continue-from))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1887 (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
|
1888 (when (interactive-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1889 (message "Checkbox statistics updated %s (%d places)" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1890 (if all "in entire file" "in current outline entry") cstat))))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1891 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1892 (defun org-get-checkbox-statistics-face () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1893 "Select the face for checkbox statistics. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1894 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
|
1895 Otherwise it will be `org-todo'." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1896 (if (match-end 1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1897 (if (equal (match-string 1) "100%") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1898 'org-checkbox-statistics-done |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1899 'org-checkbox-statistics-todo) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1900 (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
|
1901 (equal (match-string 2) (match-string 3))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1902 'org-checkbox-statistics-done |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1903 '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
|
1904 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1905 ;;; Misc Tools |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1906 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1907 (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
|
1908 "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
|
1909 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
|
1910 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
|
1911 previous item, plus ARGS extra arguments. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1912 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1913 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
|
1914 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
|
1915 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1916 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
|
1917 beginning of the item." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1918 (let* ((pos (copy-marker (point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1919 (end (copy-marker (org-list-bottom-point))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1920 (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
|
1921 (value init-value)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1922 (while (< next-p end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1923 (goto-char next-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1924 (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
|
1925 (setq value (apply function value args))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1926 (goto-char pos) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1927 value)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1928 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1929 (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
|
1930 "Sort plain list items. |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1931 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
|
1932 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
|
1933 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1934 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
|
1935 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
|
1936 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1937 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
|
1938 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
|
1939 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1940 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
|
1941 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
|
1942 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
|
1943 meaning of each character: |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1944 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1945 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
|
1946 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
|
1947 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
|
1948 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
|
1949 |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1950 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
|
1951 |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1952 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
|
1953 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
|
1954 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
|
1955 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
|
1956 compare entries." |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1957 (interactive "P") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1958 (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
|
1959 (top (org-list-top-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1960 (bottom (org-list-bottom-point)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1961 (start (org-get-beginning-of-list top)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1962 (end (org-get-end-of-list bottom)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1963 (sorting-type |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1964 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1965 (message |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1966 "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
|
1967 (read-char-exclusive))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1968 (getkey-func (and (= (downcase sorting-type) ?f) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1969 (org-icompleting-read "Sort using function: " |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1970 obarray 'fboundp t nil nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1971 (intern getkey-func)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1972 (message "Sorting items...") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1973 (save-restriction |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1974 (narrow-to-region start end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1975 (goto-char (point-min)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1976 (let* ((dcst (downcase sorting-type)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1977 (case-fold-search nil) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1978 (now (current-time)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1979 (sort-func (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1980 ((= dcst ?a) 'string<) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1981 ((= dcst ?f) compare-func) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1982 ((= dcst ?t) '<) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1983 (t nil))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1984 (begin-record (lambda () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1985 (skip-chars-forward " \r\t\n") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1986 (beginning-of-line))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1987 (end-record (lambda () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1988 (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
|
1989 (value-to-sort |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1990 (lambda () |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1991 (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
|
1992 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1993 ((= dcst ?n) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1994 (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
|
1995 (point-at-eol)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1996 ((= dcst ?a) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1997 (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
|
1998 ((= dcst ?t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
1999 (cond |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2000 ;; 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
|
2001 ((org-at-item-timer-p) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2002 (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
|
2003 ((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
|
2004 (point-at-eol) t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2005 (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
|
2006 (point-at-eol) t)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2007 (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
|
2008 (t (org-float-time now)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2009 ((= dcst ?f) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2010 (if getkey-func |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2011 (let ((value (funcall getkey-func))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2012 (if (stringp value) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2013 (funcall case-func value) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2014 value)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2015 (error "Invalid key function `%s'" getkey-func))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2016 (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
|
2017 (sort-subr (/= dcst sorting-type) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2018 begin-record |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2019 end-record |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2020 value-to-sort |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2021 nil |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2022 sort-func) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2023 (org-list-repair nil top bottom) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2024 (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
|
2025 (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
|
2026 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2027 ;;; 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
|
2028 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2029 (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
|
2030 "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
|
2031 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
|
2032 sublevels as a list of strings." |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2033 (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
|
2034 (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
|
2035 output itemsep ltype) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2036 (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
|
2037 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2038 (beginning-of-line) |
111880
a7740098b594
Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
111506
diff
changeset
|
2039 (setq ltype (cond ((org-looking-at-p "^[ \t]*[0-9]") 'ordered) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2040 ((org-at-item-description-p) 'descriptive) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2041 (t 'unordered)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2042 (let* ((indent1 (org-get-indentation)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2043 (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
|
2044 (item (org-trim (buffer-substring (point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2045 (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
|
2046 (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
|
2047 (item (if (string-match |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2048 "^\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\([xX ]\\)\\]" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2049 item) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2050 (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
|
2051 "CBOFF" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2052 "CBON") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2053 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
|
2054 item))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2055 (push item output) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2056 (when (> nextindent indent1) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2057 (save-restriction |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2058 (narrow-to-region (point) nextitem) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2059 (push (org-list-parse-list) output))))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2060 (when delete |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2061 (delete-region start end) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2062 (save-match-data |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2063 (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
|
2064 (looking-at (org-list-end-re))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2065 (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
|
2066 (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
|
2067 (push ltype output))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2068 |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2069 (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
|
2070 "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
|
2071 (interactive) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2072 (if (not (org-in-item-p)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2073 (error "Not in a list") |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2074 (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
|
2075 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2076 (if (ignore-errors |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2077 (org-back-to-heading)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2078 (progn (looking-at org-complex-heading-regexp) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2079 (setq nstars (length (match-string 1)))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2080 (setq nstars 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2081 (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
|
2082 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2083 (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
|
2084 "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
|
2085 (if (symbolp (car list)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2086 (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
|
2087 (mapcar (lambda (item) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2088 (if (stringp item) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2089 (insert (make-string |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2090 (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
|
2091 (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
|
2092 (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
|
2093 list))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
2094 |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2095 (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
|
2096 "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
|
2097 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2098 (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
|
2099 (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
|
2100 name pos) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2101 (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
|
2102 (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
|
2103 (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
|
2104 (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
|
2105 (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
|
2106 (setq pos (point)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2107 (insert txt) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2108 (goto-char pos))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2109 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2110 (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
|
2111 "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
|
2112 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
|
2113 this list." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2114 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2115 (catch 'exit |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2116 (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
|
2117 (save-excursion |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2118 (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
|
2119 (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
|
2120 (if maybe |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2121 (throw 'exit nil) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2122 (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
|
2123 (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
|
2124 (transform (intern (match-string 2))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2125 (bottom-point |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2126 (save-excursion |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2127 (re-search-forward |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2128 "\\(\\\\end{comment}\\|@end ignore\\|-->\\)" nil t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2129 (match-beginning 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2130 (top-point |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2131 (progn |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2132 (re-search-backward "#\\+ORGLST" nil t) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2133 (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
|
2134 (match-beginning 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2135 (list (save-restriction |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2136 (narrow-to-region top-point bottom-point) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2137 (org-list-parse-list))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2138 beg txt) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2139 (unless (fboundp transform) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2140 (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
|
2141 (let ((txt (funcall transform list))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2142 ;; Find the insertion place |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2143 (save-excursion |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2144 (goto-char (point-min)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2145 (unless (re-search-forward |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2146 (concat "BEGIN RECEIVE ORGLST +" |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2147 name |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2148 "\\([ \t]\\|$\\)") nil t) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2149 (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
|
2150 (goto-char (match-beginning 0)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2151 (beginning-of-line 2) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2152 (setq beg (point)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2153 (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
|
2154 (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
|
2155 (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
|
2156 (goto-char beg) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
2157 (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
|
2158 (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
|
2159 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2160 (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
|
2161 "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
|
2162 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
|
2163 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2164 :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
|
2165 :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
|
2166 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2167 :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
|
2168 :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
|
2169 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2170 :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
|
2171 :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
|
2172 :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
|
2173 :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
|
2174 :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
|
2175 :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
|
2176 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2177 :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
|
2178 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
|
2179 |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2180 :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
|
2181 :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
|
2182 :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
|
2183 :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
|
2184 |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2185 :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
|
2186 :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
|
2187 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2188 (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
|
2189 (splicep (plist-get p :splice)) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2190 (ostart (plist-get p :ostart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2191 (oend (plist-get p :oend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2192 (ustart (plist-get p :ustart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2193 (uend (plist-get p :uend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2194 (dstart (plist-get p :dstart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2195 (dend (plist-get p :dend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2196 (dtstart (plist-get p :dtstart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2197 (dtend (plist-get p :dtend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2198 (ddstart (plist-get p :ddstart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2199 (ddend (plist-get p :ddend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2200 (istart (plist-get p :istart)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2201 (iend (plist-get p :iend)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2202 (isep (plist-get p :isep)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2203 (lsep (plist-get p :lsep)) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2204 (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
|
2205 (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
|
2206 (let ((wrapper |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2207 (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
|
2208 (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
|
2209 ((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
|
2210 (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
|
2211 ((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
|
2212 (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
|
2213 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
|
2214 (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
|
2215 (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
|
2216 ((stringp sublist) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2217 (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
|
2218 (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
|
2219 (match-string 1 sublist)))) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2220 (setq sublist (concat ddstart |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2221 (org-trim (substring sublist |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2222 (match-end 0))) |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2223 ddend))) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2224 (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
|
2225 (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
|
2226 (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
|
2227 (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
|
2228 (if (string-match "\\[-\\]" sublist) |
b7d8222914b4
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
105341
diff
changeset
|
2229 (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
|
2230 (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
|
2231 (t (setq rtn (concat rtn ;; previous list |
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2232 lsep ;; list separator |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2233 (org-list-to-generic sublist p) |
111506
5cb272c831e8
Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
109812
diff
changeset
|
2234 lsep ;; list separator |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
2235 ))))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2236 (format wrapper rtn)))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2237 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2238 (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
|
2239 "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
|
2240 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
|
2241 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
|
2242 (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
|
2243 list |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2244 (org-combine-plists |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2245 '(: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
|
2246 :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
|
2247 :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
|
2248 :dtstart "[" :dtend "]" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2249 :ddstart "" :ddend "" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2250 :istart "\\item " :iend "" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2251 :isep "\n" :lsep "\n" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2252 :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
|
2253 params))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2254 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2255 (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
|
2256 "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
|
2257 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
|
2258 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
|
2259 (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
|
2260 list |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2261 (org-combine-plists |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2262 '(: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
|
2263 :ustart "<ul>" :uend "</ul>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2264 :dstart "<dl>" :dend "</dl>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2265 :dtstart "<dt>" :dtend "</dt>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2266 :ddstart "<dd>" :ddend "</dd>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2267 :istart "<li>" :iend "</li>" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2268 :isep "\n" :lsep "\n" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2269 :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
|
2270 params))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2271 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2272 (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
|
2273 "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
|
2274 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
|
2275 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
|
2276 (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
|
2277 list |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2278 (org-combine-plists |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2279 '(: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
|
2280 :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
|
2281 :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
|
2282 :dtstart "@item " :dtend "\n" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2283 :ddstart "" :ddend "" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2284 :istart "@item\n" :iend "" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2285 :isep "\n" :lsep "\n" |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
2286 :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
|
2287 params))) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2288 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2289 (provide 'org-list) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2290 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2291 ;;; org-list.el ends here |