annotate lisp/org/org.el @ 94730:3bbff46b7130

Meta-CVS support removed.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Wed, 07 May 2008 22:11:08 +0000
parents ba3167bc4143
children 494fe8a4eeb0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; org.el --- Outline-based notes management and organizer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2 ;; Carstens outline-mode for keeping track of everything.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6 ;; Keywords: outlines, hypermedia, calendar, wp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7 ;; Homepage: http://orgmode.org
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8 ;; Version: 6.02b
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11 ;;
94676
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94457
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
94676
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94457
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94457
diff changeset
15 ;; (at your option) any later version.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
16
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
20 ;; GNU General Public License for more details.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
21
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94676
ba3167bc4143 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94457
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
26 ;;; Commentary:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
27 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
28 ;; Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29 ;; project planning with a fast and effective plain-text system.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 ;; Org-mode develops organizational tasks around NOTES files that contain
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 ;; information about projects as plain text. Org-mode is implemented on
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 ;; top of outline-mode, which makes it possible to keep the content of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34 ;; large files well structured. Visibility cycling and structure editing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 ;; help to work with the tree. Tables are easily created with a built-in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 ;; table editor. Org-mode supports ToDo items, deadlines, time stamps,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 ;; and scheduling. It dynamically compiles entries into an agenda that
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38 ;; utilizes and smoothly integrates much of the Emacs calendar and diary.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 ;; Plain text URL-like links connect to websites, emails, Usenet
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40 ;; messages, BBDB entries, and any files related to the projects. For
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 ;; printing and sharing of notes, an Org-mode file can be exported as a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42 ;; structured ASCII file, as HTML, or (todo and agenda items only) as an
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43 ;; iCalendar file. It can also serve as a publishing tool for a set of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 ;; linked webpages.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 ;; Installation and Activation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 ;; ---------------------------
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 ;; See the corresponding sections in the manual at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 ;; http://orgmode.org/org.html#Installation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 ;; Documentation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53 ;; -------------
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54 ;; The documentation of Org-mode can be found in the TeXInfo file. The
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55 ;; distribution also contains a PDF version of it. At the homepage of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56 ;; Org-mode, you can read the same text online as HTML. There is also an
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 ;; excellent reference card made by Philip Rooke. This card can be found
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58 ;; in the etc/ directory of Emacs 22.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 ;; A list of recent changes can be found at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 ;; http://orgmode.org/Changes.html
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 ;;
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63 ;;; Code:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
65 (defvar org-inhibit-highlight-removal nil) ; dynamically scoped param
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
66 (defvar org-table-formula-constants-local nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
67 "Local version of `org-table-formula-constants'.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
68 (make-variable-buffer-local 'org-table-formula-constants-local)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
69
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70 ;;;; Require other packages
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72 (eval-when-compile
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
73 (require 'cl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74 (require 'gnus-sum)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
75 (require 'calendar))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76 ;; For XEmacs, noutline is not yet provided by outline.el, so arrange for
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77 ;; the file noutline.el being loaded.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
78 (if (featurep 'xemacs) (condition-case nil (require 'noutline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79 ;; We require noutline, which might be provided in outline.el
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80 (require 'outline) (require 'noutline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81 ;; Other stuff we need.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 (require 'time-date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 (unless (fboundp 'time-subtract) (defalias 'time-subtract 'subtract-time))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
84 (require 'easymenu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
86 (require 'org-macs)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
87 (require 'org-compat)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
88 (require 'org-faces)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
89
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
90 ;;;; Customization variables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
91
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92 ;;; Version
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
94 (defconst org-version "6.02b"
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95 "The version number of the file org.el.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
97 (defun org-version (&optional here)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 "Show the org-mode version in the echo area.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99 With prefix arg HERE, insert it at point."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101 (let ((version (format "Org-mode version %s" org-version)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102 (message version)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103 (if here
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 (insert version))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 ;;; Compatibility constants
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108 ;;; The custom variables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 (defgroup org nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 "Outline-based notes management and organizer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 :tag "Org"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 :group 'outlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 :group 'hypermedia
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115 :group 'calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 (defcustom org-load-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 "Hook that is run after org.el has been loaded."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 :group 'org
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
122 (defvar org-modules) ; defined below
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
123 (defvar org-modules-loaded nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
124 "Have the modules been loaded already?")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
125
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
126 (defun org-load-modules-maybe (&optional force)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
127 "Load all extensions listed in `org-default-extensions'."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
128 (when (or force (not org-modules-loaded))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
129 (mapc (lambda (ext)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
130 (condition-case nil (require ext)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
131 (error (message "Problems while trying to load feature `%s'" ext))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
132 org-modules)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
133 (setq org-modules-loaded t)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
134
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
135 (defun org-set-modules (var value)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
136 "Set VAR to VALUE and call `org-load-modules-maybe' with the force flag."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
137 (set var value)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
138 (when (featurep 'org)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
139 (org-load-modules-maybe 'force)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
140
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
141 (defcustom org-modules '(org-bbdb org-bibtex org-gnus org-info org-infojs org-irc org-mew org-mhe org-rmail org-vm org-wl)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
142 "Modules that should always be loaded together with org.el.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
143 If a description starts with <C>, the file is not part of emacs
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
144 and loading it will require that you have downloaded and properly installed
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
145 the org-mode distribution.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
146
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
147 You can also use this system to load external packages (i.e. neither Org
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
148 core modules, not modules from the CONTRIB directory). Just add symbols
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
149 to the end of the list. If the package is called org-xyz.e, then you need
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
150 to add the symbol `xyz', and the package must have a call to
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
151
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
152 (provide 'org-xyz)"
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 :group 'org
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
154 :set 'org-set-modules
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
155 :type
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
156 '(set :greedy t
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
157 (const :tag " bbdb: Links to BBDB entries" org-bbdb)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
158 (const :tag " bibtex: Links to BibTeX entries" org-bibtex)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
159 (const :tag " gnus: Links to GNUS folders/messages" org-gnus)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
160 (const :tag " info: Links to Info nodes" org-info)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
161 (const :tag " infojs: Set up Sebastian Rose's JavaScript org-info.js" org-infojs)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
162 (const :tag " irc: Links to IRC/ERC chat sessions" org-irc)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
163 (const :tag " mac-message: Links to messages in Apple Mail" org-mac-message)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
164 (const :tag " mew Links to Mew folders/messages" org-mew)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
165 (const :tag " mhe: Links to MHE folders/messages" org-mhe)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
166 (const :tag " rmail: Links to RMAIL folders/messages" org-rmail)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
167 (const :tag " vm: Links to VM folders/messages" org-vm)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
168 (const :tag " wl: Links to Wanderlust folders/messages" org-wl)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
169 (const :tag " mouse: Additional mouse support" org-mouse)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
170
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
171 (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
172 (const :tag "C bookmark: Org links to bookmarks" org-bookmark)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
173 (const :tag "C depend: TODO dependencies for Org-mode" org-depend)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
174 (const :tag "C elisp-symbol: Org links to emacs-lisp symbols" org-elisp-symbol)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
175 (const :tag "C expiry: Expiry mechanism for Org entries" org-expiry)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
176 (const :tag "C id: Global id's for identifying entries" org-id)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
177 (const :tag "C interactive-query: Interactive modification of tags query" org-interactive-query)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
178 (const :tag "C mairix: Hook mairix search into Org for different MUAs" org-mairix)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
179 (const :tag "C man: Support for links to manpages in Org-mode" org-man)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
180 (const :tag "C mew: Support for links to messages in Mew" org-mew)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
181 (const :tag "C panel: Simple routines for us with bad memory" org-panel)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
182 (const :tag "C registry: A registry for Org links" org-registry)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
183 (const :tag "C org2rem: Convert org appointments into reminders" org2rem)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
184 (const :tag "C screen: Visit screen sessions through Org-mode links" org-screen)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
185 (const :tag "C toc: Table of contents for Org-mode buffer" org-toc)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
186 (const :tag "C sqlinsert: Convert Org-mode tables to SQL insertions" orgtbl-sqlinsert)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
187 (repeat :tag "External packages" :inline t (symbol :tag "Package"))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
188
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 (defgroup org-startup nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 "Options concerning startup of Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 :tag "Org Startup"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 (defcustom org-startup-folded t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196 "Non-nil means, entering Org-mode will switch to OVERVIEW.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 This can also be configured on a per-file basis by adding one of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198 the following lines anywhere in the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 #+STARTUP: fold
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 #+STARTUP: nofold
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 #+STARTUP: content"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 (const :tag "nofold: show all" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206 (const :tag "fold: overview" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 (const :tag "content: all headlines" content)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 (defcustom org-startup-truncated t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210 "Non-nil means, entering Org-mode will set `truncate-lines'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 This is useful since some lines containing links can be very long and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 uninteresting. Also tables look terrible when wrapped."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 (defcustom org-startup-align-all-tables nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 "Non-nil means, align all tables when visiting a file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 This is useful when the column width in tables is forced with <N> cookies
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219 in table fields. Such tables will look correct only after the first re-align.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220 This can also be configured on a per-file basis by adding one of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 the following lines anywhere in the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
222 #+STARTUP: align
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
223 #+STARTUP: noalign"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
227 (defcustom org-insert-mode-line-in-empty-file nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
228 "Non-nil means insert the first line setting Org-mode in empty files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
229 When the function `org-mode' is called interactively in an empty file, this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
230 normally means that the file name does not automatically trigger Org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
231 To ensure that the file will always be in Org-mode in the future, a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 line enforcing Org-mode will be inserted into the buffer, if this option
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 has been set."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
236
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
237 (defcustom org-replace-disputed-keys nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
238 "Non-nil means use alternative key bindings for some keys.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 Org-mode uses S-<cursor> keys for changing timestamps and priorities.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 These keys are also used by other packages like `CUA-mode' or `windmove.el'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
241 If you want to use Org-mode together with one of these other modes,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 or more generally if you would like to move some Org-mode commands to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 other keys, set this variable and configure the keys with the variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244 `org-disputed-keys'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
246 This option is only relevant at load-time of Org-mode, and must be set
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
247 *before* org.el is loaded. Changing it requires a restart of Emacs to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
248 become effective."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
249 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 (if (fboundp 'defvaralias)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 (defvaralias 'org-CUA-compatible 'org-replace-disputed-keys))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255 (defcustom org-disputed-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256 '(([(shift up)] . [(meta p)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 ([(shift down)] . [(meta n)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258 ([(shift left)] . [(meta -)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 ([(shift right)] . [(meta +)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
260 ([(control shift right)] . [(meta shift +)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 ([(control shift left)] . [(meta shift -)]))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262 "Keys for which Org-mode and other modes compete.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 This is an alist, cars are the default keys, second element specifies
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
264 the alternative to use when `org-replace-disputed-keys' is t.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
265
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
266 Keys can be specified in any syntax supported by `define-key'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
267 The value of this option takes effect only at Org-mode's startup,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
268 therefore you'll have to restart Emacs to apply it after changing."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
269 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
270 :type 'alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
271
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272 (defun org-key (key)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273 "Select key according to `org-replace-disputed-keys' and `org-disputed-keys'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 Or return the original if not disputed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
275 (if org-replace-disputed-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
276 (let* ((nkey (key-description key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277 (x (org-find-if (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278 (equal (key-description (car x)) nkey))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279 org-disputed-keys)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
280 (if x (cdr x) key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283 (defun org-find-if (predicate seq)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
285 (while seq
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
286 (if (funcall predicate (car seq))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
287 (throw 'exit (car seq))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288 (pop seq)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290 (defun org-defkey (keymap key def)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 "Define a key, possibly translated, as returned by `org-key'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292 (define-key keymap (org-key key) def))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 (defcustom org-ellipsis nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295 "The ellipsis to use in the Org-mode outline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 When nil, just use the standard three dots. When a string, use that instead,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 When a face, use the standart 3 dots, but with the specified face.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298 The change affects only Org-mode (which will then use its own display table).
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
299 Changing this requires executing `M-x org-mode' in a buffer to become
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
300 effective."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
301 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302 :type '(choice (const :tag "Default" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
303 (face :tag "Face" :value org-warning)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
304 (string :tag "String" :value "...#")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
305
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
306 (defvar org-display-table nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307 "The display table for org-mode, in case `org-ellipsis' is non-nil.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
308
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
309 (defgroup org-keywords nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
310 "Keywords in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
311 :tag "Org Keywords"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
312 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
313
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
314 (defcustom org-deadline-string "DEADLINE:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315 "String to mark deadline entries.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
316 A deadline is this string, followed by a time stamp. Should be a word,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
317 terminated by a colon. You can insert a schedule keyword and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
318 a timestamp with \\[org-deadline].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
319 Changes become only effective after restarting Emacs."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
320 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
321 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
322
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
323 (defcustom org-scheduled-string "SCHEDULED:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
324 "String to mark scheduled TODO entries.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
325 A schedule is this string, followed by a time stamp. Should be a word,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
326 terminated by a colon. You can insert a schedule keyword and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
327 a timestamp with \\[org-schedule].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
328 Changes become only effective after restarting Emacs."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
329 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
330 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332 (defcustom org-closed-string "CLOSED:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
333 "String used as the prefix for timestamps logging closing a TODO entry."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
334 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
335 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
336
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
337 (defcustom org-clock-string "CLOCK:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
338 "String used as prefix for timestamps clocking work hours on an item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
339 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
340 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
341
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
342 (defcustom org-comment-string "COMMENT"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343 "Entries starting with this keyword will never be exported.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
344 An entry can be toggled between COMMENT and normal with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
345 \\[org-toggle-comment].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
346 Changes become only effective after restarting Emacs."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
347 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
348 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
349
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
350 (defcustom org-quote-string "QUOTE"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
351 "Entries starting with this keyword will be exported in fixed-width font.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
352 Quoting applies only to the text in the entry following the headline, and does
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
353 not extend beyond the next headline, even if that is lower level.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
354 An entry can be toggled between QUOTE and normal with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
355 \\[org-toggle-fixed-width-section]."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
356 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
357 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
358
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
359 (defconst org-repeat-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
360 "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*\\([.+]?\\+[0-9]+[dwmy]\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
361 "Regular expression for specifying repeated events.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
362 After a match, group 1 contains the repeat expression.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
363
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
364 (defgroup org-structure nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
365 "Options concerning the general structure of Org-mode files."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
366 :tag "Org Structure"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
367 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
368
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
369 (defgroup org-reveal-location nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
370 "Options about how to make context of a location visible."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
371 :tag "Org Reveal Location"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
372 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
373
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
374 (defconst org-context-choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
375 '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
376 (const :tag "Always" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 (repeat :greedy t :tag "Individual contexts"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379 (cons
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 (choice :tag "Context"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 (const agenda)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
382 (const org-goto)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383 (const occur-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
384 (const tags-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385 (const link-search)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 (const mark-goto)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
387 (const bookmark-jump)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 (const isearch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389 (const default))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390 (boolean))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391 "Contexts for the reveal options.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
392
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393 (defcustom org-show-hierarchy-above '((default . t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
394 "Non-nil means, show full hierarchy when revealing a location.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
395 Org-mode often shows locations in an org-mode file which might have
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
396 been invisible before. When this is set, the hierarchy of headings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
397 above the exposed location is shown.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
398 Turning this off for example for sparse trees makes them very compact.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
399 Instead of t, this can also be an alist specifying this option for different
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 contexts. Valid contexts are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401 agenda when exposing an entry from the agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402 org-goto when using the command `org-goto' on key C-c C-j
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403 occur-tree when using the command `org-occur' on key C-c /
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
404 tags-tree when constructing a sparse tree based on tags matches
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
405 link-search when exposing search matches associated with a link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
406 mark-goto when exposing the jump goal of a mark
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407 bookmark-jump when exposing a bookmark location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 isearch when exiting from an incremental search
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409 default default for all contexts not set explicitly"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
410 :group 'org-reveal-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
411 :type org-context-choice)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
412
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413 (defcustom org-show-following-heading '((default . nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
414 "Non-nil means, show following heading when revealing a location.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
415 Org-mode often shows locations in an org-mode file which might have
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
416 been invisible before. When this is set, the heading following the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
417 match is shown.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
418 Turning this off for example for sparse trees makes them very compact,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
419 but makes it harder to edit the location of the match. In such a case,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
420 use the command \\[org-reveal] to show more context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
421 Instead of t, this can also be an alist specifying this option for different
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
422 contexts. See `org-show-hierarchy-above' for valid contexts."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
423 :group 'org-reveal-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
424 :type org-context-choice)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
425
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
426 (defcustom org-show-siblings '((default . nil) (isearch t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427 "Non-nil means, show all sibling heading when revealing a location.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 Org-mode often shows locations in an org-mode file which might have
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 been invisible before. When this is set, the sibling of the current entry
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 heading are all made visible. If `org-show-hierarchy-above' is t,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
431 the same happens on each level of the hierarchy above the current entry.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
432
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
433 By default this is on for the isearch context, off for all other contexts.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
434 Turning this off for example for sparse trees makes them very compact,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
435 but makes it harder to edit the location of the match. In such a case,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
436 use the command \\[org-reveal] to show more context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
437 Instead of t, this can also be an alist specifying this option for different
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
438 contexts. See `org-show-hierarchy-above' for valid contexts."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
439 :group 'org-reveal-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
440 :type org-context-choice)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
441
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442 (defcustom org-show-entry-below '((default . nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
443 "Non-nil means, show the entry below a headline when revealing a location.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
444 Org-mode often shows locations in an org-mode file which might have
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
445 been invisible before. When this is set, the text below the headline that is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
446 exposed is also shown.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 By default this is off for all contexts.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
449 Instead of t, this can also be an alist specifying this option for different
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
450 contexts. See `org-show-hierarchy-above' for valid contexts."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
451 :group 'org-reveal-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
452 :type org-context-choice)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
454 (defcustom org-indirect-buffer-display 'other-window
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
455 "How should indirect tree buffers be displayed?
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
456 This applies to indirect buffers created with the commands
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
457 \\[org-tree-to-indirect-buffer] and \\[org-agenda-tree-to-indirect-buffer].
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
458 Valid values are:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
459 current-window Display in the current window
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
460 other-window Just display in another window.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
461 dedicated-frame Create one new frame, and re-use it each time.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
462 new-frame Make a new frame each time. Note that in this case
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
463 previously-made indirect buffers are kept, and you need to
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
464 kill these buffers yourself."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
465 :group 'org-structure
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
466 :group 'org-agenda-windows
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
467 :type '(choice
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
468 (const :tag "In current window" current-window)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
469 (const :tag "In current frame, other window" other-window)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
470 (const :tag "Each time a new frame" new-frame)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
471 (const :tag "One dedicated frame" dedicated-frame)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
472
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
473 (defgroup org-cycle nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
474 "Options concerning visibility cycling in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
475 :tag "Org Cycle"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
476 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
477
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
478 (defcustom org-drawers '("PROPERTIES" "CLOCK")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 "Names of drawers. Drawers are not opened by cycling on the headline above.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480 Drawers only open with a TAB on the drawer line itself. A drawer looks like
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481 this:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482 :DRAWERNAME:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
483 .....
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
484 :END:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 The drawer \"PROPERTIES\" is special for capturing properties through
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 the property API.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
487
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
488 Drawers can be defined on the per-file basis with a line like:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
489
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
490 #+DRAWERS: HIDDEN STATE PROPERTIES"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
491 :group 'org-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
492 :type '(repeat (string :tag "Drawer Name")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
493
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
494 (defcustom org-cycle-global-at-bob nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
495 "Cycle globally if cursor is at beginning of buffer and not at a headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
496 This makes it possible to do global cycling without having to use S-TAB or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
497 C-u TAB. For this special case to work, the first line of the buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
498 must not be a headline - it may be empty ot some other text. When used in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
499 this way, `org-cycle-hook' is disables temporarily, to make sure the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
500 cursor stays at the beginning of the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
501 When this option is nil, don't do anything special at the beginning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
502 of the buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503 :group 'org-cycle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
504 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
505
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
506 (defcustom org-cycle-emulate-tab t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
507 "Where should `org-cycle' emulate TAB.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
508 nil Never
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
509 white Only in completely white lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
510 whitestart Only at the beginning of lines, before the first non-white char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 t Everywhere except in headlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 exc-hl-bol Everywhere except at the start of a headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
513 If TAB is used in a place where it does not emulate TAB, the current subtree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
514 visibility is cycled."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515 :group 'org-cycle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 :type '(choice (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517 (const :tag "Only in completely white lines" white)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
518 (const :tag "Before first char in a line" whitestart)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
519 (const :tag "Everywhere except in headlines" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520 (const :tag "Everywhere except at bol in headlines" exc-hl-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
521 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
522
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
523 (defcustom org-cycle-separator-lines 2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 "Number of empty lines needed to keep an empty line between collapsed trees.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525 If you leave an empty line between the end of a subtree and the following
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526 headline, this empty line is hidden when the subtree is folded.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
527 Org-mode will leave (exactly) one empty line visible if the number of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528 empty lines is equal or larger to the number given in this variable.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 So the default 2 means, at least 2 empty lines after the end of a subtree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 are needed to produce free space between a collapsed subtree and the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 following headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 Special case: when 0, never leave empty lines in collapsed view."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 :group 'org-cycle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
535 :type 'integer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
536
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537 (defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 org-cycle-hide-drawers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 org-cycle-show-empty-lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 org-optimize-window-after-visibility-change)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541 "Hook that is run after `org-cycle' has changed the buffer visibility.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
542 The function(s) in this hook must accept a single argument which indicates
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
543 the new state that was set by the most recent `org-cycle' command. The
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544 argument is a symbol. After a global state change, it can have the values
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545 `overview', `content', or `all'. After a local state change, it can have
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
546 the values `folded', `children', or `subtree'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547 :group 'org-cycle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
548 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550 (defgroup org-edit-structure nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551 "Options concerning structure editing in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 :tag "Org Edit Structure"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
555 (defcustom org-odd-levels-only nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556 "Non-nil means, skip even levels and only use odd levels for the outline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 This has the effect that two stars are being added/taken away in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558 promotion/demotion commands. It also influences how levels are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 handled by the exporters.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 Changing it requires restart of `font-lock-mode' to become effective
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 for fontification also in regions already fontified.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 You may also set this on a per-file basis by adding one of the following
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 lines to the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 #+STARTUP: odd
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 #+STARTUP: oddeven"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 (defcustom org-adapt-indentation t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 "Non-nil means, adapt indentation when promoting and demoting.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 When this is set and the *entire* text in an entry is indented, the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 indentation is increased by one space in a demotion command, and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 decreased by one in a promotion command. If any line in the entry
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 body starts at column 0, indentation is not changed at all."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
579
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
580 (defcustom org-special-ctrl-a/e nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
581 "Non-nil means `C-a' and `C-e' behave specially in headlines and items.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582 When t, `C-a' will bring back the cursor to the beginning of the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
583 headline text, i.e. after the stars and after a possible TODO keyword.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 In an item, this will be the position after the bullet.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585 When the cursor is already at that position, another `C-a' will bring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586 it to the beginning of the line.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587 `C-e' will jump to the end of the headline, ignoring the presence of tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 in the headline. A second `C-e' will then jump to the true end of the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589 line, after any tags.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 When set to the symbol `reversed', the first `C-a' or `C-e' works normally,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591 and only a directly following, identical keypress will bring the cursor
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592 to the special positions."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
595 (const :tag "off" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596 (const :tag "after bullet first" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597 (const :tag "border first" reversed)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
599 (if (fboundp 'defvaralias)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
600 (defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
601
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602 (defcustom org-special-ctrl-k nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 "Non-nil means `C-k' will behave specially in headlines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604 When nil, `C-k' will call the default `kill-line' command.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 When t, the following will happen while the cursor is in the headline:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607 - When the cursor is at the beginning of a headline, kill the entire
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
608 line and possible the folded subtree below the line.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 - When in the middle of the headline text, kill the headline up to the tags.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
610 - When after the headline text, kill the tags."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
611 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
612 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614 (defcustom org-M-RET-may-split-line '((default . t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 "Non-nil means, M-RET will split the line at the cursor position.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 When nil, it will go to the end of the line before making a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
617 new line.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 You may also set this option in a different way for different
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619 contexts. Valid contexts are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
620
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
621 headline when creating a new headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
622 item when creating a new item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
623 table in a table field
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
624 default the value to be used for all contexts not explicitly
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
625 customized"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
626 :group 'org-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
627 :group 'org-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
628 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
629 (const :tag "Always" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
630 (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
631 (repeat :greedy t :tag "Individual contexts"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
632 (cons
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
633 (choice :tag "Context"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
634 (const headline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
635 (const item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
636 (const table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
637 (const default))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
638 (boolean)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
639
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
640
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
641 (defcustom org-blank-before-new-entry '((heading . nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
642 (plain-list-item . nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
643 "Should `org-insert-heading' leave a blank line before new heading/item?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
644 The value is an alist, with `heading' and `plain-list-item' as car,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
645 and a boolean flag as cdr."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
646 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
647 :type '(list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
648 (cons (const heading) (boolean))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
649 (cons (const plain-list-item) (boolean))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
650
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
651 (defcustom org-insert-heading-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
652 "Hook being run after inserting a new heading."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
653 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
654 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
655
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656 (defcustom org-enable-fixed-width-editor t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
657 "Non-nil means, lines starting with \":\" are treated as fixed-width.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
658 This currently only means, they are never auto-wrapped.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
659 When nil, such lines will be treated like ordinary lines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
660 See also the QUOTE keyword."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
661 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
663
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 (defcustom org-goto-auto-isearch t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
665 "Non-nil means, typing characters in org-goto starts incremental search."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
668
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
669 (defgroup org-sparse-trees nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
670 "Options concerning sparse trees in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
671 :tag "Org Sparse Trees"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
672 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
673
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
674 (defcustom org-highlight-sparse-tree-matches t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
675 "Non-nil means, highlight all matches that define a sparse tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
676 The highlights will automatically disappear the next time the buffer is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
677 changed by an edit command."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
678 :group 'org-sparse-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
679 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
680
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
681 (defcustom org-remove-highlights-with-change t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
682 "Non-nil means, any change to the buffer will remove temporary highlights.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
683 Such highlights are created by `org-occur' and `org-clock-display'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
684 When nil, `C-c C-c needs to be used to get rid of the highlights.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
685 The highlights created by `org-preview-latex-fragment' always need
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
686 `C-c C-c' to be removed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
687 :group 'org-sparse-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
688 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
689 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
690
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
691
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
692 (defcustom org-occur-hook '(org-first-headline-recenter)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693 "Hook that is run after `org-occur' has constructed a sparse tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
694 This can be used to recenter the window to show as much of the structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
695 as possible."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696 :group 'org-sparse-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
697 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
698
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
699 (defgroup org-plain-lists nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
700 "Options concerning plain lists in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
701 :tag "Org Plain lists"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
702 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
703
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
704 (defcustom org-cycle-include-plain-lists nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
705 "Non-nil means, include plain lists into visibility cycling.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
706 This means that during cycling, plain list items will *temporarily* be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
707 interpreted as outline headlines with a level given by 1000+i where i is the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
708 indentation of the bullet. In all other operations, plain list items are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
709 not seen as headlines. For example, you cannot assign a TODO keyword to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
710 such an item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
711 :group 'org-plain-lists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
712 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
713
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
714 (defcustom org-plain-list-ordered-item-terminator t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
715 "The character that makes a line with leading number an ordered list item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
716 Valid values are ?. and ?\). To get both terminators, use t. While
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
717 ?. may look nicer, it creates the danger that a line with leading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
718 number may be incorrectly interpreted as an item. ?\) therefore is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
719 the safe choice."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
720 :group 'org-plain-lists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
721 :type '(choice (const :tag "dot like in \"2.\"" ?.)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
722 (const :tag "paren like in \"2)\"" ?\))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
723 (const :tab "both" t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
724
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
725 (defcustom org-empty-line-terminates-plain-lists nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
726 "Non-nil means, an empty line ends all plain list levels.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
727 When nil, empty lines are part of the preceeding item."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
728 :group 'org-plain-lists
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
729 :type 'boolean)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
730
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
731 (defcustom org-auto-renumber-ordered-lists t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
732 "Non-nil means, automatically renumber ordered plain lists.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
733 Renumbering happens when the sequence have been changed with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
734 \\[org-shiftmetaup] or \\[org-shiftmetadown]. After other editing commands,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
735 use \\[org-ctrl-c-ctrl-c] to trigger renumbering."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
736 :group 'org-plain-lists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
737 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
738
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739 (defcustom org-provide-checkbox-statistics t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
740 "Non-nil means, update checkbox statistics after insert and toggle.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
741 When this is set, checkbox statistics is updated each time you either insert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742 a new checkbox with \\[org-insert-todo-heading] or toggle a checkbox
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
743 with \\[org-ctrl-c-ctrl-c\\]."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
744 :group 'org-plain-lists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
747
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
748 (defgroup org-imenu-and-speedbar nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749 "Options concerning imenu and speedbar in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
750 :tag "Org Imenu and Speedbar"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
751 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
753 (defcustom org-imenu-depth 2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
754 "The maximum level for Imenu access to Org-mode headlines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755 This also applied for speedbar access."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756 :group 'org-imenu-and-speedbar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
757 :type 'number)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
758
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
759 (defgroup org-table nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
760 "Options concerning tables in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
761 :tag "Org Table"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
762 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
764 (defcustom org-enable-table-editor 'optimized
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
765 "Non-nil means, lines starting with \"|\" are handled by the table editor.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
766 When nil, such lines will be treated like ordinary lines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
767
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
768 When equal to the symbol `optimized', the table editor will be optimized to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
769 do the following:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
770 - Automatic overwrite mode in front of whitespace in table fields.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 This makes the structure of the table stay in tact as long as the edited
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
772 field does not exceed the column width.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
773 - Minimize the number of realigns. Normally, the table is aligned each time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774 TAB or RET are pressed to move to another field. With optimization this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
775 happens only if changes to a field might have changed the column width.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776 Optimization requires replacing the functions `self-insert-command',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
777 `delete-char', and `backward-delete-char' in Org-mode buffers, with a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
778 slight (in fact: unnoticeable) speed impact for normal typing. Org-mode is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
779 very good at guessing when a re-align will be necessary, but you can always
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
780 force one with \\[org-ctrl-c-ctrl-c].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
781
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
782 If you would like to use the optimized version in Org-mode, but the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
783 un-optimized version in OrgTbl-mode, see the variable `orgtbl-optimized'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
784
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
785 This variable can be used to turn on and off the table editor during a session,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
786 but in order to toggle optimization, a restart is required.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
787
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
788 See also the variable `org-table-auto-blank-field'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
789 :group 'org-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
790 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
791 (const :tag "off" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
792 (const :tag "on" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
793 (const :tag "on, optimized" optimized)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
794
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
795 (defcustom org-table-tab-recognizes-table.el t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
796 "Non-nil means, TAB will automatically notice a table.el table.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
797 When it sees such a table, it moves point into it and - if necessary -
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 calls `table-recognize-table'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
799 :group 'org-table-editing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
800 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
801
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
802 (defgroup org-link nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
803 "Options concerning links in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
804 :tag "Org Link"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
805 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
806
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
807 (defvar org-link-abbrev-alist-local nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
808 "Buffer-local version of `org-link-abbrev-alist', which see.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
809 The value of this is taken from the #+LINK lines.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
810 (make-variable-buffer-local 'org-link-abbrev-alist-local)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
811
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
812 (defcustom org-link-abbrev-alist nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
813 "Alist of link abbreviations.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
814 The car of each element is a string, to be replaced at the start of a link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
815 The cdrs are replacement values, like (\"linkkey\" . REPLACE). Abbreviated
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
816 links in Org-mode buffers can have an optional tag after a double colon, e.g.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
817
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
818 [[linkkey:tag][description]]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
819
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
820 If REPLACE is a string, the tag will simply be appended to create the link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
821 If the string contains \"%s\", the tag will be inserted there.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
822
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
823 REPLACE may also be a function that will be called with the tag as the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
824 only argument to create the link, which should be returned as a string.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
825
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
826 See the manual for examples."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
827 :group 'org-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
828 :type 'alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
829
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
830 (defcustom org-descriptive-links t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
831 "Non-nil means, hide link part and only show description of bracket links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
832 Bracket links are like [[link][descritpion]]. This variable sets the initial
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
833 state in new org-mode buffers. The setting can then be toggled on a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
834 per-buffer basis from the Org->Hyperlinks menu."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
835 :group 'org-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
836 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
837
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
838 (defcustom org-link-file-path-type 'adaptive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
839 "How the path name in file links should be stored.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
840 Valid values are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
841
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
842 relative Relative to the current directory, i.e. the directory of the file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
843 into which the link is being inserted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
844 absolute Absolute path, if possible with ~ for home directory.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
845 noabbrev Absolute path, no abbreviation of home directory.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
846 adaptive Use relative path for files in the current directory and sub-
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
847 directories of it. For other files, use an absolute path."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
848 :group 'org-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
849 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
850 (const relative)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851 (const absolute)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
852 (const noabbrev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
853 (const adaptive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
854
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
855 (defcustom org-activate-links '(bracket angle plain radio tag date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
856 "Types of links that should be activated in Org-mode files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
857 This is a list of symbols, each leading to the activation of a certain link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
858 type. In principle, it does not hurt to turn on most link types - there may
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
859 be a small gain when turning off unused link types. The types are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
860
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
861 bracket The recommended [[link][description]] or [[link]] links with hiding.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
862 angular Links in angular brackes that may contain whitespace like
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
863 <bbdb:Carsten Dominik>.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
864 plain Plain links in normal text, no whitespace, like http://google.com.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
865 radio Text that is matched by a radio target, see manual for details.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
866 tag Tag settings in a headline (link to tag search).
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
867 date Time stamps (link to calendar).
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
868
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
869 Changing this variable requires a restart of Emacs to become effective."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
870 :group 'org-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
871 :type '(set (const :tag "Double bracket links (new style)" bracket)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
872 (const :tag "Angular bracket links (old style)" angular)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
873 (const :tag "Plain text links" plain)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
874 (const :tag "Radio target matches" radio)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
875 (const :tag "Tags" tag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
876 (const :tag "Timestamps" date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
877
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
878 (defcustom org-make-link-description-function nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
879 "Function to use to generate link descriptions from links. If
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
880 nil the link location will be used. This function must take two
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
881 parameters; the first is the link and the second the description
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
882 org-insert-link has generated, and should return the description
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
883 to use."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
884 :group 'org-link
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
885 :type 'function)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
886
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
887 (defgroup org-link-store nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
888 "Options concerning storing links in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
889 :tag "Org Store Link"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
890 :group 'org-link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
891
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
892 (defcustom org-email-link-description-format "Email %c: %.30s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
893 "Format of the description part of a link to an email or usenet message.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
894 The following %-excapes will be replaced by corresponding information:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
895
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
896 %F full \"From\" field
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
897 %f name, taken from \"From\" field, address if no name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
898 %T full \"To\" field
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
899 %t first name in \"To\" field, address if no name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
900 %c correspondent. Unually \"from NAME\", but if you sent it yourself, it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
901 will be \"to NAME\". See also the variable `org-from-is-user-regexp'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
902 %s subject
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
903 %m message-id.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
904
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
905 You may use normal field width specification between the % and the letter.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
906 This is for example useful to limit the length of the subject.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
907
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
908 Examples: \"%f on: %.30s\", \"Email from %f\", \"Email %c\""
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
909 :group 'org-link-store
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
910 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
911
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
912 (defcustom org-from-is-user-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
913 (let (r1 r2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
914 (when (and user-mail-address (not (string= user-mail-address "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
915 (setq r1 (concat "\\<" (regexp-quote user-mail-address) "\\>")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
916 (when (and user-full-name (not (string= user-full-name "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
917 (setq r2 (concat "\\<" (regexp-quote user-full-name) "\\>")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
918 (if (and r1 r2) (concat r1 "\\|" r2) (or r1 r2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
919 "Regexp mached against the \"From:\" header of an email or usenet message.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
920 It should match if the message is from the user him/herself."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
921 :group 'org-link-store
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
922 :type 'regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
923
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
924 (defcustom org-context-in-file-links t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
925 "Non-nil means, file links from `org-store-link' contain context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926 A search string will be added to the file name with :: as separator and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
927 used to find the context when the link is activated by the command
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
928 `org-open-at-point'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
929 Using a prefix arg to the command \\[org-store-link] (`org-store-link')
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
930 negates this setting for the duration of the command."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
931 :group 'org-link-store
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
932 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
933
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
934 (defcustom org-keep-stored-link-after-insertion nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
935 "Non-nil means, keep link in list for entire session.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
936
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
937 The command `org-store-link' adds a link pointing to the current
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
938 location to an internal list. These links accumulate during a session.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
939 The command `org-insert-link' can be used to insert links into any
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
940 Org-mode file (offering completion for all stored links). When this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
941 option is nil, every link which has been inserted once using \\[org-insert-link]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
942 will be removed from the list, to make completing the unused links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
943 more efficient."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
944 :group 'org-link-store
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
945 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
946
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
947 (defgroup org-link-follow nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
948 "Options concerning following links in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
949 :tag "Org Follow Link"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
950 :group 'org-link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
951
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
952 (defcustom org-follow-link-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
953 "Hook that is run after a link has been followed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
954 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
955 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
956
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
957 (defcustom org-tab-follows-link nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
958 "Non-nil means, on links TAB will follow the link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
959 Needs to be set before org.el is loaded."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
960 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
961 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
962
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
963 (defcustom org-return-follows-link nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
964 "Non-nil means, on links RET will follow the link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
965 Needs to be set before org.el is loaded."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
966 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
967 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
968
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
969 (defcustom org-mouse-1-follows-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
970 (if (boundp 'mouse-1-click-follows-link) mouse-1-click-follows-link t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
971 "Non-nil means, mouse-1 on a link will follow the link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
972 A longer mouse click will still set point. Does not work on XEmacs.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
973 Needs to be set before org.el is loaded."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
975 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
976
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
977 (defcustom org-mark-ring-length 4
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
978 "Number of different positions to be recorded in the ring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
979 Changing this requires a restart of Emacs to work correctly."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
980 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981 :type 'interger)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
982
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
983 (defcustom org-link-frame-setup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
984 '((vm . vm-visit-folder-other-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
985 (gnus . gnus-other-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
986 (file . find-file-other-window))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
987 "Setup the frame configuration for following links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
988 When following a link with Emacs, it may often be useful to display
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
989 this link in another window or frame. This variable can be used to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
990 set this up for the different types of links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
991 For VM, use any of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
992 `vm-visit-folder'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
993 `vm-visit-folder-other-frame'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
994 For Gnus, use any of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
995 `gnus'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
996 `gnus-other-frame'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
997 For FILE, use any of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
998 `find-file'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
999 `find-file-other-window'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1000 `find-file-other-frame'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1001 For the calendar, use the variable `calendar-setup'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1002 For BBDB, it is currently only possible to display the matches in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1003 another window."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1004 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1005 :type '(list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006 (cons (const vm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1007 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1008 (const vm-visit-folder)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1009 (const vm-visit-folder-other-window)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1010 (const vm-visit-folder-other-frame)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1011 (cons (const gnus)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1012 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1013 (const gnus)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1014 (const gnus-other-frame)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1015 (cons (const file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1016 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1017 (const find-file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1018 (const find-file-other-window)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1019 (const find-file-other-frame)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1020
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1021 (defcustom org-display-internal-link-with-indirect-buffer nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1022 "Non-nil means, use indirect buffer to display infile links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1023 Activating internal links (from one location in a file to another location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1024 in the same file) normally just jumps to the location. When the link is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1025 activated with a C-u prefix (or with mouse-3), the link is displayed in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1026 another window. When this option is set, the other window actually displays
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1027 an indirect buffer clone of the current buffer, to avoid any visibility
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1028 changes to the current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1029 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1030 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1031
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1032 (defcustom org-open-non-existing-files nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1033 "Non-nil means, `org-open-file' will open non-existing files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1034 When nil, an error will be generated."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1035 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1036 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1037
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1038 (defcustom org-link-mailto-program '(browse-url "mailto:%a?subject=%s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1039 "Function and arguments to call for following mailto links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1040 This is a list with the first element being a lisp function, and the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1041 remaining elements being arguments to the function. In string arguments,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1042 %a will be replaced by the address, and %s will be replaced by the subject
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1043 if one was given like in <mailto:arthur@galaxy.org::this subject>."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1044 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1045 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1046 (const :tag "browse-url" (browse-url-mail "mailto:%a?subject=%s"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1047 (const :tag "compose-mail" (compose-mail "%a" "%s"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1048 (const :tag "message-mail" (message-mail "%a" "%s"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1049 (cons :tag "other" (function) (repeat :tag "argument" sexp))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1050
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1051 (defcustom org-confirm-shell-link-function 'yes-or-no-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1052 "Non-nil means, ask for confirmation before executing shell links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1053 Shell links can be dangerous: just think about a link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1054
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1055 [[shell:rm -rf ~/*][Google Search]]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1056
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1057 This link would show up in your Org-mode document as \"Google Search\",
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1058 but really it would remove your entire home directory.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1059 Therefore we advise against setting this variable to nil.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1060 Just change it to `y-or-n-p' of you want to confirm with a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1061 single keystroke rather than having to type \"yes\"."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1062 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1063 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1064 (const :tag "with yes-or-no (safer)" yes-or-no-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1065 (const :tag "with y-or-n (faster)" y-or-n-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1066 (const :tag "no confirmation (dangerous)" nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1067
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1068 (defcustom org-confirm-elisp-link-function 'yes-or-no-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1069 "Non-nil means, ask for confirmation before executing Emacs Lisp links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1070 Elisp links can be dangerous: just think about a link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1071
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1072 [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1073
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1074 This link would show up in your Org-mode document as \"Google Search\",
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1075 but really it would remove your entire home directory.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1076 Therefore we advise against setting this variable to nil.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1077 Just change it to `y-or-n-p' of you want to confirm with a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1078 single keystroke rather than having to type \"yes\"."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1079 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1080 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1081 (const :tag "with yes-or-no (safer)" yes-or-no-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1082 (const :tag "with y-or-n (faster)" y-or-n-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1083 (const :tag "no confirmation (dangerous)" nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1084
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1085 (defconst org-file-apps-defaults-gnu
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1086 '((remote . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1087 (t . mailcap))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1088 "Default file applications on a UNIX or GNU/Linux system.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1089 See `org-file-apps'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1090
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1091 (defconst org-file-apps-defaults-macosx
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1092 '((remote . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1093 (t . "open %s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1094 ("ps" . "gv %s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1095 ("ps.gz" . "gv %s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1096 ("eps" . "gv %s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1097 ("eps.gz" . "gv %s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1098 ("dvi" . "xdvi %s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1099 ("fig" . "xfig %s"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1100 "Default file applications on a MacOS X system.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1101 The system \"open\" is known as a default, but we use X11 applications
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1102 for some files for which the OS does not have a good default.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1103 See `org-file-apps'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1104
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1105 (defconst org-file-apps-defaults-windowsnt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1106 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1107 '(remote . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1108 (cons t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1109 (list (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1110 'mswindows-shell-execute
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1111 'w32-shell-execute)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1112 "open" 'file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1113 "Default file applications on a Windows NT system.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1114 The system \"open\" is used for most files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1115 See `org-file-apps'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1116
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1117 (defcustom org-file-apps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1118 '(
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1119 ("txt" . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1120 ("tex" . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1121 ("ltx" . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1122 ("org" . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1123 ("el" . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1124 ("bib" . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1125 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1126 "External applications for opening `file:path' items in a document.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1127 Org-mode uses system defaults for different file types, but
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1128 you can use this variable to set the application for a given file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1129 extension. The entries in this list are cons cells where the car identifies
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1130 files and the cdr the corresponding command. Possible values for the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1131 file identifier are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1132 \"ext\" A string identifying an extension
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1133 `directory' Matches a directory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1134 `remote' Matches a remote file, accessible through tramp or efs.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1135 Remote files most likely should be visited through Emacs
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1136 because external applications cannot handle such paths.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1137 t Default for all remaining files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1138
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1139 Possible values for the command are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1140 `emacs' The file will be visited by the current Emacs process.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1141 `default' Use the default application for this file type.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1142 string A command to be executed by a shell; %s will be replaced
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1143 by the path to the file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1144 sexp A Lisp form which will be evaluated. The file path will
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1145 be available in the Lisp variable `file'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1146 For more examples, see the system specific constants
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1147 `org-file-apps-defaults-macosx'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1148 `org-file-apps-defaults-windowsnt'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1149 `org-file-apps-defaults-gnu'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1150 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1151 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1152 (cons (choice :value ""
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1153 (string :tag "Extension")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1154 (const :tag "Default for unrecognized files" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1155 (const :tag "Remote file" remote)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1156 (const :tag "Links to a directory" directory))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1157 (choice :value ""
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1158 (const :tag "Visit with Emacs" emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1159 (const :tag "Use system default" default)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1160 (string :tag "Command")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1161 (sexp :tag "Lisp form")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1162
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1163 (defgroup org-refile nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1164 "Options concerning refiling entries in Org-mode."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1165 :tag "Org Remember"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1166 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1167
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1168 (defcustom org-directory "~/org"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1169 "Directory with org files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1170 This directory will be used as default to prompt for org files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1171 Used by the hooks for remember.el."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1172 :group 'org-refile
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1173 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1174 :type 'directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1175
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1176 (defcustom org-default-notes-file "~/.notes"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1177 "Default target for storing notes.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1178 Used by the hooks for remember.el. This can be a string, or nil to mean
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1179 the value of `remember-data-file'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1180 You can set this on a per-template basis with the variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1181 `org-remember-templates'."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1182 :group 'org-refile
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1183 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1184 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1185 (const :tag "Default from remember-data-file" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1186 file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1187
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1188 (defcustom org-goto-interface 'outline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1189 "The default interface to be used for `org-goto'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1190 Allowed vaues are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1191 outline The interface shows an outline of the relevant file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1192 and the correct heading is found by moving through
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1193 the outline or by searching with incremental search.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1194 outline-path-completion Headlines in the current buffer are offered via
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1195 completion."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1196 :group 'org-refile
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1197 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1198 (const :tag "Outline" outline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1199 (const :tag "Outline-path-completion" outline-path-completion)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1200
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1201 (defcustom org-reverse-note-order nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1202 "Non-nil means, store new notes at the beginning of a file or entry.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1203 When nil, new notes will be filed to the end of a file or entry.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1204 This can also be a list with cons cells of regular expressions that
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1205 are matched against file names, and values."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1206 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1207 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1208 (const :tag "Reverse always" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1209 (const :tag "Reverse never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1210 (repeat :tag "By file name regexp"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1211 (cons regexp boolean))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1212
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1213 (defcustom org-refile-targets nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1214 "Targets for refiling entries with \\[org-refile].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1215 This is list of cons cells. Each cell contains:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1216 - a specification of the files to be considered, either a list of files,
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1217 or a symbol whose function or variable value will be used to retrieve
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1218 a file name or a list of file names. Nil means, refile to a different
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1219 heading in the current buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1220 - A specification of how to find candidate refile targets. This may be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1221 any of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1222 - a cons cell (:tag . \"TAG\") to identify refile targets by a tag.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1223 This tag has to be present in all target headlines, inheritance will
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1224 not be considered.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1225 - a cons cell (:todo . \"KEYWORD\") to identify refile targets by
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1226 todo keyword.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1227 - a cons cell (:regexp . \"REGEXP\") with a regular expression matching
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1228 headlines that are refiling targets.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1229 - a cons cell (:level . N). Any headline of level N is considered a target.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1230 - a cons cell (:maxlevel . N). Any headline with level <= N is a target."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1231 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1232 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1233 (cons
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1234 (choice :value org-agenda-files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1235 (const :tag "All agenda files" org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1236 (const :tag "Current buffer" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1237 (function) (variable) (file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1238 (choice :tag "Identify target headline by"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1239 (cons :tag "Specific tag" (const :tag) (string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1240 (cons :tag "TODO keyword" (const :todo) (string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1241 (cons :tag "Regular expression" (const :regexp) (regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1242 (cons :tag "Level number" (const :level) (integer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1243 (cons :tag "Max Level number" (const :maxlevel) (integer))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1244
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1245 (defcustom org-refile-use-outline-path nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1246 "Non-nil means, provide refile targets as paths.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1247 So a level 3 headline will be available as level1/level2/level3.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1248 When the value is `file', also include the file name (without directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1249 into the path. When `full-file-path', include the full file path."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1250 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1251 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1252 (const :tag "Not" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1253 (const :tag "Yes" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1254 (const :tag "Start with file name" file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1255 (const :tag "Start with full file path" full-file-path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1256
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1257 (defgroup org-todo nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1258 "Options concerning TODO items in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1259 :tag "Org TODO"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1260 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1261
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1262 (defgroup org-progress nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1263 "Options concerning Progress logging in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1264 :tag "Org Progress"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1265 :group 'org-time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1266
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1267 (defcustom org-todo-keywords '((sequence "TODO" "DONE"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1268 "List of TODO entry keyword sequences and their interpretation.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1269 \\<org-mode-map>This is a list of sequences.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1270
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1271 Each sequence starts with a symbol, either `sequence' or `type',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1272 indicating if the keywords should be interpreted as a sequence of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1273 action steps, or as different types of TODO items. The first
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1274 keywords are states requiring action - these states will select a headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1275 for inclusion into the global TODO list Org-mode produces. If one of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1276 the \"keywords\" is the vertical bat \"|\" the remaining keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1277 signify that no further action is necessary. If \"|\" is not found,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1278 the last keyword is treated as the only DONE state of the sequence.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1279
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1280 The command \\[org-todo] cycles an entry through these states, and one
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1281 additional state where no keyword is present. For details about this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1282 cycling, see the manual.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1283
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1284 TODO keywords and interpretation can also be set on a per-file basis with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1285 the special #+SEQ_TODO and #+TYP_TODO lines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1286
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1287 Each keyword can optionally specify a character for fast state selection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1288 \(in combination with the variable `org-use-fast-todo-selection')
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1289 and specifiers for state change logging, using the same syntax
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1290 that is used in the \"#+TODO:\" lines. For example, \"WAIT(w)\" says
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1291 that the WAIT state can be selected with the \"w\" key. \"WAIT(w!)\"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1292 indicates to record a time stamp each time this state is selected.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1293
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1294 Each keyword may also specify if a timestamp or a note should be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1295 recorded when entering or leaving the state, by adding additional
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1296 characters in the parenthesis after the keyword. This looks like this:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1297 \"WAIT(w@/!)\". \"@\" means to add a note (with time), \"!\" means to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1298 record only the time of the state change. With X and Y being either
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1299 \"@\" or \"!\", \"X/Y\" means use X when entering the state, and use
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1300 Y when leaving the state if and only if the *target* state does not
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1301 define X. You may omit any of the fast-selection key or X or /Y,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1302 so WAIT(w@), WAIT(w/@) and WAIT(@/@) are all valid.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1303
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1304 For backward compatibility, this variable may also be just a list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1305 of keywords - in this case the interptetation (sequence or type) will be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1306 taken from the (otherwise obsolete) variable `org-todo-interpretation'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1307 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1308 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1309 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1310 (repeat :tag "Old syntax, just keywords"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1311 (string :tag "Keyword"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1312 (repeat :tag "New syntax"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1313 (cons
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1314 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1315 :tag "Interpretation"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1316 (const :tag "Sequence (cycling hits every state)" sequence)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1317 (const :tag "Type (cycling directly to DONE)" type))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1318 (repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1319 (string :tag "Keyword"))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1320
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1321 (defvar org-todo-keywords-1 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1322 "All TODO and DONE keywords active in a buffer.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1323 (make-variable-buffer-local 'org-todo-keywords-1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1324 (defvar org-todo-keywords-for-agenda nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1325 (defvar org-done-keywords-for-agenda nil)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1326 (defvar org-agenda-contributing-files nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1327 (defvar org-not-done-keywords nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1328 (make-variable-buffer-local 'org-not-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1329 (defvar org-done-keywords nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1330 (make-variable-buffer-local 'org-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1331 (defvar org-todo-heads nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1332 (make-variable-buffer-local 'org-todo-heads)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1333 (defvar org-todo-sets nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1334 (make-variable-buffer-local 'org-todo-sets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1335 (defvar org-todo-log-states nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1336 (make-variable-buffer-local 'org-todo-log-states)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1337 (defvar org-todo-kwd-alist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1338 (make-variable-buffer-local 'org-todo-kwd-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1339 (defvar org-todo-key-alist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1340 (make-variable-buffer-local 'org-todo-key-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1341 (defvar org-todo-key-trigger nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1342 (make-variable-buffer-local 'org-todo-key-trigger)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1343
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1344 (defcustom org-todo-interpretation 'sequence
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1345 "Controls how TODO keywords are interpreted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1346 This variable is in principle obsolete and is only used for
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1347 backward compatibility, if the interpretation of todo keywords is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1348 not given already in `org-todo-keywords'. See that variable for
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1349 more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1350 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1351 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1352 :type '(choice (const sequence)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1353 (const type)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1354
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1355 (defcustom org-use-fast-todo-selection 'prefix
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1356 "Non-nil means, use the fast todo selection scheme with C-c C-t.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1357 This variable describes if and under what circumstances the cycling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1358 mechanism for TODO keywords will be replaced by a single-key, direct
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1359 selection scheme.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1360
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1361 When nil, fast selection is never used.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1362
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1363 When the symbol `prefix', it will be used when `org-todo' is called with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1364 a prefix argument, i.e. `C-u C-c C-t' in an Org-mode buffer, and `C-u t'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1365 in an agenda buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1366
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1367 When t, fast selection is used by default. In this case, the prefix
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1368 argument forces cycling instead.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1369
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1370 In all cases, the special interface is only used if access keys have actually
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1371 been assigned by the user, i.e. if keywords in the configuration are followed
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1372 by a letter in parenthesis, like TODO(t)."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1373 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1374 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1375 (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1376 (const :tag "By default" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1377 (const :tag "Only with C-u C-c C-t" prefix)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1378
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1379 (defcustom org-after-todo-state-change-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1380 "Hook which is run after the state of a TODO item was changed.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1381 The new state (a string with a TODO keyword, or nil) is available in the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1382 Lisp variable `state'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1383 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1384 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1385
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1386 (defcustom org-log-done nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1387 "Non-nil means, record a CLOSED timestamp when moving an entry to DONE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1388 When equal to the list (done), also prompt for a closing note.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1389 This can also be configured on a per-file basis by adding one of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1390 the following lines anywhere in the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1391
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1392 #+STARTUP: logdone
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1393 #+STARTUP: lognotedone
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1394 #+STARTUP: nologdone"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1395 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1396 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1397 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1398 (const :tag "No logging" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1399 (const :tag "Record CLOSED timestamp" time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1400 (const :tag "Record CLOSED timestamp with closing note." note)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1401
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1402 ;; Normalize old uses of org-log-done.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1403 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1404 ((eq org-log-done t) (setq org-log-done 'time))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1405 ((and (listp org-log-done) (memq 'done org-log-done))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1406 (setq org-log-done 'note)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1407
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1408 (defcustom org-log-note-clock-out nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1409 "Non-nil means, recored a note when clocking out of an item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1410 This can also be configured on a per-file basis by adding one of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1411 the following lines anywhere in the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1412
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1413 #+STARTUP: lognoteclock-out
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1414 #+STARTUP: nolognoteclock-out"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1415 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1416 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1417 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1418
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1419 (defcustom org-log-done-with-time t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1420 "Non-nil means, the CLOSED time stamp will contain date and time.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1421 When nil, only the date will be recorded."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1422 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1423 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1424
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1425 (defcustom org-log-note-headings
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1426 '((done . "CLOSING NOTE %t")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1427 (state . "State %-12s %t")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1428 (note . "Note taken on %t")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1429 (clock-out . ""))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1430 "Headings for notes added to entries.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1431 The value is an alist, with the car being a symbol indicating the note
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1432 context, and the cdr is the heading to be used. The heading may also be the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1433 empty string.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1434 %t in the heading will be replaced by a time stamp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1435 %s will be replaced by the new TODO state, in double quotes.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1436 %u will be replaced by the user name.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1437 %U will be replaced by the full user name."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1438 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1439 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1440 :type '(list :greedy t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1441 (cons (const :tag "Heading when closing an item" done) string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1442 (cons (const :tag
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1443 "Heading when changing todo state (todo sequence only)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1444 state) string)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1445 (cons (const :tag "Heading when just taking a note" note) string)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1446 (cons (const :tag "Heading when clocking out" clock-out) string)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1447
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1448 (unless (assq 'note org-log-note-headings)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1449 (push '(note . "%t") org-log-note-headings))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1450
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1451 (defcustom org-log-states-order-reversed t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1452 "Non-nil means, the latest state change note will be directly after heading.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1453 When nil, the notes will be orderer according to time."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1454 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1455 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1456 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1457
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1458 (defcustom org-log-repeat 'time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1459 "Non-nil means, record moving through the DONE state when triggering repeat.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1460 An auto-repeating tasks is immediately switched back to TODO when marked
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1461 done. If you are not logging state changes (by adding \"@\" or \"!\" to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1462 the TODO keyword definition, or recording a cloing note by setting
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1463 `org-log-done', there will be no record of the task moving trhough DONE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1464 This variable forces taking a note anyway. Possible values are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1465
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1466 nil Don't force a record
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1467 time Record a time stamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1468 note Record a note
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1469
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1470 This option can also be set with on a per-file-basis with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1471
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1472 #+STARTUP: logrepeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1473 #+STARTUP: lognoterepeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1474 #+STARTUP: nologrepeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1475
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1476 You can have local logging settings for a subtree by setting the LOGGING
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1477 property to one or more of these keywords."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1478 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1479 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1480 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1481 (const :tag "Don't force a record" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1482 (const :tag "Force recording the DONE state" time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1483 (const :tag "Force recording a note with the DONE state" note)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1484
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1485
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1486 (defgroup org-priorities nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1487 "Priorities in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1488 :tag "Org Priorities"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1489 :group 'org-todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1490
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1491 (defcustom org-highest-priority ?A
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1492 "The highest priority of TODO items. A character like ?A, ?B etc.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1493 Must have a smaller ASCII number than `org-lowest-priority'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1494 :group 'org-priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1495 :type 'character)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1496
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1497 (defcustom org-lowest-priority ?C
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1498 "The lowest priority of TODO items. A character like ?A, ?B etc.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1499 Must have a larger ASCII number than `org-highest-priority'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1500 :group 'org-priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1501 :type 'character)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1502
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1503 (defcustom org-default-priority ?B
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1504 "The default priority of TODO items.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1505 This is the priority an item get if no explicit priority is given."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1506 :group 'org-priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1507 :type 'character)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1508
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1509 (defcustom org-priority-start-cycle-with-default t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1510 "Non-nil means, start with default priority when starting to cycle.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1511 When this is nil, the first step in the cycle will be (depending on the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1512 command used) one higher or lower that the default priority."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1513 :group 'org-priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1514 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1515
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1516 (defgroup org-time nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1517 "Options concerning time stamps and deadlines in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1518 :tag "Org Time"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1519 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1520
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1521 (defcustom org-insert-labeled-timestamps-at-point nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1522 "Non-nil means, SCHEDULED and DEADLINE timestamps are inserted at point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1523 When nil, these labeled time stamps are forces into the second line of an
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1524 entry, just after the headline. When scheduling from the global TODO list,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1525 the time stamp will always be forced into the second line."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1526 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1527 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1528
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1529 (defconst org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1530 "Formats for `format-time-string' which are used for time stamps.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1531 It is not recommended to change this constant.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1532
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1533 (defcustom org-time-stamp-rounding-minutes '(0 5)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1534 "Number of minutes to round time stamps to.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1535 These are two values, the first applies when first creating a time stamp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1536 The second applies when changing it with the commands `S-up' and `S-down'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1537 When changing the time stamp, this means that it will change in steps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1538 of N minutes, as given by the second value.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1539
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1540 When a setting is 0 or 1, insert the time unmodified. Useful rounding
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1541 numbers should be factors of 60, so for example 5, 10, 15.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1542
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1543 When this is larger than 1, you can still force an exact time-stamp by using
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1544 a double prefix argument to a time-stamp command like `C-c .' or `C-c !',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1545 and by using a prefix arg to `S-up/down' to specify the exact number
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1546 of minutes to shift."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1547 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1548 :get '(lambda (var) ; Make sure all entries have 5 elements
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1549 (if (integerp (default-value var))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1550 (list (default-value var) 5)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1551 (default-value var)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1552 :type '(list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1553 (integer :tag "when inserting times")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1554 (integer :tag "when modifying times")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1555
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1556 ;; Normalize old customizations of this variable.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1557 (when (integerp org-time-stamp-rounding-minutes)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1558 (setq org-time-stamp-rounding-minutes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1559 (list org-time-stamp-rounding-minutes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1560 org-time-stamp-rounding-minutes)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1561
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1562 (defcustom org-display-custom-times nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1563 "Non-nil means, overlay custom formats over all time stamps.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1564 The formats are defined through the variable `org-time-stamp-custom-formats'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1565 To turn this on on a per-file basis, insert anywhere in the file:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1566 #+STARTUP: customtime"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1567 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1568 :set 'set-default
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1569 :type 'sexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1570 (make-variable-buffer-local 'org-display-custom-times)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1571
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1572 (defcustom org-time-stamp-custom-formats
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1573 '("<%m/%d/%y %a>" . "<%m/%d/%y %a %H:%M>") ; american
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1574 "Custom formats for time stamps. See `format-time-string' for the syntax.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1575 These are overlayed over the default ISO format if the variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1576 `org-display-custom-times' is set. Time like %H:%M should be at the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1577 end of the second format."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1578 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1579 :type 'sexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1580
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1581 (defun org-time-stamp-format (&optional long inactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1582 "Get the right format for a time string."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1583 (let ((f (if long (cdr org-time-stamp-formats)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1584 (car org-time-stamp-formats))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1585 (if inactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1586 (concat "[" (substring f 1 -1) "]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1587 f)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1588
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1589 (defcustom org-deadline-warning-days 14
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1590 "No. of days before expiration during which a deadline becomes active.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1591 This variable governs the display in sparse trees and in the agenda.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1592 When 0 or negative, it means use this number (the absolute value of it)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1593 even if a deadline has a different individual lead time specified."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1594 :group 'org-time
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1595 :group 'org-agenda-daily/weekly
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1596 :type 'number)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1597
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1598 (defcustom org-read-date-prefer-future t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1599 "Non-nil means, assume future for incomplete date input from user.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1600 This affects the following situations:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1601 1. The user gives a day, but no month.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1602 For example, if today is the 15th, and you enter \"3\", Org-mode will
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1603 read this as the third of *next* month. However, if you enter \"17\",
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1604 it will be considered as *this* month.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1605 2. The user gives a month but not a year.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1606 For example, if it is april and you enter \"feb 2\", this will be read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1607 as feb 2, *next* year. \"May 5\", however, will be this year.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1608
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1609 Currently this does not work for ISO week specifications.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1610
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1611 When this option is nil, the current month and year will always be used
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1612 as defaults."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1613 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1614 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1615
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1616 (defcustom org-read-date-display-live t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1617 "Non-nil means, display current interpretation of date prompt live.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1618 This display will be in an overlay, in the minibuffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1619 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1620 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1621
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1622 (defcustom org-read-date-popup-calendar t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1623 "Non-nil means, pop up a calendar when prompting for a date.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1624 In the calendar, the date can be selected with mouse-1. However, the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1625 minibuffer will also be active, and you can simply enter the date as well.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1626 When nil, only the minibuffer will be available."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1627 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1628 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1629 (if (fboundp 'defvaralias)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1630 (defvaralias 'org-popup-calendar-for-date-prompt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1631 'org-read-date-popup-calendar))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1632
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1633 (defcustom org-extend-today-until 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1634 "The hour when your day really ends.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1635 This has influence for the following applications:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1636 - When switching the agenda to \"today\". It it is still earlier than
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1637 the time given here, the day recognized as TODAY is actually yesterday.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1638 - When a date is read from the user and it is still before the time given
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1639 here, the current date and time will be assumed to be yesterday, 23:59.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1640
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1641 FIXME:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1642 IMPORTANT: This is still a very experimental feature, it may disappear
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1643 again or it may be extended to mean more things."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1644 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1645 :type 'number)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1646
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1647 (defcustom org-edit-timestamp-down-means-later nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1648 "Non-nil means, S-down will increase the time in a time stamp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1649 When nil, S-up will increase."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1650 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1651 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1652
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1653 (defcustom org-calendar-follow-timestamp-change t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1654 "Non-nil means, make the calendar window follow timestamp changes.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1655 When a timestamp is modified and the calendar window is visible, it will be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1656 moved to the new date."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1657 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1658 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1659
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1660 (defgroup org-tags nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1661 "Options concerning tags in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1662 :tag "Org Tags"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1663 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1664
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1665 (defcustom org-tag-alist nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1666 "List of tags allowed in Org-mode files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1667 When this list is nil, Org-mode will base TAG input on what is already in the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1668 buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1669 The value of this variable is an alist, the car of each entry must be a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1670 keyword as a string, the cdr may be a character that is used to select
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1671 that tag through the fast-tag-selection interface.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1672 See the manual for details."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1673 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1674 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1675 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1676 (cons (string :tag "Tag name")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1677 (character :tag "Access char"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1678 (const :tag "Start radio group" (:startgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1679 (const :tag "End radio group" (:endgroup)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1680
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1681 (defcustom org-use-fast-tag-selection 'auto
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1682 "Non-nil means, use fast tag selection scheme.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1683 This is a special interface to select and deselect tags with single keys.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1684 When nil, fast selection is never used.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1685 When the symbol `auto', fast selection is used if and only if selection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1686 characters for tags have been configured, either through the variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1687 `org-tag-alist' or through a #+TAGS line in the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1688 When t, fast selection is always used and selection keys are assigned
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1689 automatically if necessary."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1690 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1691 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1692 (const :tag "Always" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1693 (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1694 (const :tag "When selection characters are configured" 'auto)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1695
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1696 (defcustom org-fast-tag-selection-single-key nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1697 "Non-nil means, fast tag selection exits after first change.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1698 When nil, you have to press RET to exit it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1699 During fast tag selection, you can toggle this flag with `C-c'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1700 This variable can also have the value `expert'. In this case, the window
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1701 displaying the tags menu is not even shown, until you press C-c again."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1702 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1703 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1704 (const :tag "No" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1705 (const :tag "Yes" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1706 (const :tag "Expert" expert)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1707
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1708 (defvar org-fast-tag-selection-include-todo nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1709 "Non-nil means, fast tags selection interface will also offer TODO states.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1710 This is an undocumented feature, you should not rely on it.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1711
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1712 (defcustom org-tags-column (if (featurep 'xemacs) -79 -80)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1713 "The column to which tags should be indented in a headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1714 If this number is positive, it specifies the column. If it is negative,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1715 it means that the tags should be flushright to that column. For example,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1716 -80 works well for a normal 80 character screen."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1717 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1718 :type 'integer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1719
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1720 (defcustom org-auto-align-tags t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1721 "Non-nil means, realign tags after pro/demotion of TODO state change.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1722 These operations change the length of a headline and therefore shift
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1723 the tags around. With this options turned on, after each such operation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1724 the tags are again aligned to `org-tags-column'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1725 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1726 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1727
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1728 (defcustom org-use-tag-inheritance t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1729 "Non-nil means, tags in levels apply also for sublevels.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1730 When nil, only the tags directly given in a specific line apply there.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1731 If you turn off this option, you very likely want to turn on the
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1732 companion option `org-tags-match-list-sublevels'.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1733
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1734 This may also be a list of tags that should be inherited, or a regexp that
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1735 matches tags that should be inherited."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1736 :group 'org-tags
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1737 :type '(choice
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1738 (const :tag "Not" nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1739 (const :tag "Always" t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1740 (repeat :tag "Specific tags" (string :tag "Tag"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1741 (regexp :tag "Tags matched by regexp")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1742
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1743 (defun org-tag-inherit-p (tag)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1744 "Check if TAG is one that should be inherited."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1745 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1746 ((eq org-use-tag-inheritance t) t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1747 ((not org-use-tag-inheritance) nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1748 ((stringp org-use-tag-inheritance)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1749 (string-match org-use-tag-inheritance tag))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1750 ((listp org-use-tag-inheritance)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1751 (member tag org-use-tag-inheritance))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1752 (t (error "Invalid setting of `org-use-tag-inheritance'"))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1753
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1754 (defcustom org-tags-match-list-sublevels nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1755 "Non-nil means list also sublevels of headlines matching tag search.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1756 Because of tag inheritance (see variable `org-use-tag-inheritance'),
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1757 the sublevels of a headline matching a tag search often also match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1758 the same search. Listing all of them can create very long lists.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1759 Setting this variable to nil causes subtrees of a match to be skipped.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1760 This option is off by default, because inheritance in on. If you turn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1761 inheritance off, you very likely want to turn this option on.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1762
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1763 As a special case, if the tag search is restricted to TODO items, the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1764 value of this variable is ignored and sublevels are always checked, to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1765 make sure all corresponding TODO items find their way into the list."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1766 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1767 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1768
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1769 (defvar org-tags-history nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1770 "History of minibuffer reads for tags.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1771 (defvar org-last-tags-completion-table nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1772 "The last used completion table for tags.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1773 (defvar org-after-tags-change-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1774 "Hook that is run after the tags in a line have changed.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1775
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1776 (defgroup org-properties nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1777 "Options concerning properties in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1778 :tag "Org Properties"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1779 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1780
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1781 (defcustom org-property-format "%-10s %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1782 "How property key/value pairs should be formatted by `indent-line'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1783 When `indent-line' hits a property definition, it will format the line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1784 according to this format, mainly to make sure that the values are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1785 lined-up with respect to each other."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1786 :group 'org-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1787 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1788
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1789 (defcustom org-use-property-inheritance nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1790 "Non-nil means, properties apply also for sublevels.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1791
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1792 This setting is chiefly used during property searches. Turning it on can
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1793 cause significant overhead when doing a search, which is why it is not
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1794 on by default.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1795
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1796 When nil, only the properties directly given in the current entry count.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1797 When t, every property is inherited. The value may also be a list of
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1798 properties that should have inheritance, or a regular expression matching
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1799 properties that should be inherited.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1800
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1801 However, note that some special properties use inheritance under special
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1802 circumstances (not in searches). Examples are CATEGORY, ARCHIVE, COLUMNS,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1803 and the properties ending in \"_ALL\" when they are used as descriptor
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1804 for valid values of a property.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1805
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1806 Note for programmers:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1807 When querying an entry with `org-entry-get', you can control if inheritance
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1808 should be used. By default, `org-entry-get' looks only at the local
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1809 properties. You can request inheritance by setting the inherit argument
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1810 to t (to force inheritance) or to `selective' (to respect the setting
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1811 in this variable)."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1812 :group 'org-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1813 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1814 (const :tag "Not" nil)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1815 (const :tag "Always" t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1816 (repeat :tag "Specific properties" (string :tag "Property"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1817 (regexp :tag "Properties matched by regexp")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1818
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1819 (defun org-property-inherit-p (property)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1820 "Check if PROPERTY is one that should be inherited."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1821 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1822 ((eq org-use-property-inheritance t) t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1823 ((not org-use-property-inheritance) nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1824 ((stringp org-use-property-inheritance)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1825 (string-match org-use-property-inheritance property))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1826 ((listp org-use-property-inheritance)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1827 (member property org-use-property-inheritance))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1828 (t (error "Invalid setting of `org-use-property-inheritance'"))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1829
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1830 (defcustom org-columns-default-format "%25ITEM %TODO %3PRIORITY %TAGS"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1831 "The default column format, if no other format has been defined.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1832 This variable can be set on the per-file basis by inserting a line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1833
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1834 #+COLUMNS: %25ITEM ....."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1835 :group 'org-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1836 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1837
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1838 (defcustom org-effort-property "Effort"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1839 "The property that is being used to keep track of effort estimates.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1840 Effort estimates given in this property need to have the format H:MM."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1841 :group 'org-properties
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1842 :group 'org-progress
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1843 :type '(string :tag "Property"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1844
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1845 (defcustom org-global-properties nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1846 "List of property/value pairs that can be inherited by any entry.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1847 You can set buffer-local values for this by adding lines like
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1848
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1849 #+PROPERTY: NAME VALUE"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1850 :group 'org-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1851 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1852 (cons (string :tag "Property")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1853 (string :tag "Value"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1854
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1855 (defvar org-local-properties nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1856 "List of property/value pairs that can be inherited by any entry.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1857 Valid for the current buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1858 This variable is populated from #+PROPERTY lines.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1859
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1860 (defgroup org-agenda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1861 "Options concerning agenda views in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1862 :tag "Org Agenda"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1863 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1864
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1865 (defvar org-category nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1866 "Variable used by org files to set a category for agenda display.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1867 Such files should use a file variable to set it, for example
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1868
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1869 # -*- mode: org; org-category: \"ELisp\"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1870
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1871 or contain a special line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1872
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1873 #+CATEGORY: ELisp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1874
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1875 If the file does not specify a category, then file's base name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1876 is used instead.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1877 (make-variable-buffer-local 'org-category)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1878
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1879 (defcustom org-agenda-files nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1880 "The files to be used for agenda display.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1881 Entries may be added to this list with \\[org-agenda-file-to-front] and removed with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1882 \\[org-remove-file]. You can also use customize to edit the list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1883
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1884 If an entry is a directory, all files in that directory that are matched by
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1885 `org-agenda-file-regexp' will be part of the file list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1886
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1887 If the value of the variable is not a list but a single file name, then
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1888 the list of agenda files is actually stored and maintained in that file, one
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1889 agenda file per line."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1890 :group 'org-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1891 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1892 (repeat :tag "List of files and directories" file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1893 (file :tag "Store list in a file\n" :value "~/.agenda_files")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1894
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1895 (defcustom org-agenda-file-regexp "\\`[^.].*\\.org\\'"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1896 "Regular expression to match files for `org-agenda-files'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1897 If any element in the list in that variable contains a directory instead
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1898 of a normal file, all files in that directory that are matched by this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1899 regular expression will be included."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1900 :group 'org-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1901 :type 'regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1902
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1903 (defcustom org-agenda-text-search-extra-files nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1904 "List of extra files to be searched by text search commands.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1905 These files will be search in addition to the agenda files by the
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1906 commands `org-search-view' (`C-c a s') and `org-occur-in-agenda-files'.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1907 Note that these files will only be searched for text search commands,
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1908 not for the other agenda views like todo lists, tag searches or the weekly
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1909 agenda. This variable is intended to list notes and possibly archive files
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1910 that should also be searched by these two commands.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1911 In fact, if the first element in the list is the symbol `agenda-archives',
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1912 than all archive files of all agenda files will be added to the search
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1913 scope."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1914 :group 'org-agenda
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1915 :type '(set :greedy t
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1916 (const :tag "Agenda Archives" agenda-archives)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1917 (repeat :inline t (file))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1918
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1919 (if (fboundp 'defvaralias)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1920 (defvaralias 'org-agenda-multi-occur-extra-files
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1921 'org-agenda-text-search-extra-files))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1922
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1923 (defcustom org-agenda-skip-unavailable-files nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1924 "t means to just skip non-reachable files in `org-agenda-files'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1925 Nil means to remove them, after a query, from the list."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1926 :group 'org-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1927 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1928
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1929 (defcustom org-calendar-to-agenda-key [?c]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1930 "The key to be installed in `calendar-mode-map' for switching to the agenda.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1931 The command `org-calendar-goto-agenda' will be bound to this key. The
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1932 default is the character `c' because then `c' can be used to switch back and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1933 forth between agenda and calendar."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1934 :group 'org-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1935 :type 'sexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1936
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1937 (eval-after-load "calendar"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1938 '(org-defkey calendar-mode-map org-calendar-to-agenda-key
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1939 'org-calendar-goto-agenda))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1940
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1941 (defgroup org-latex nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1942 "Options for embedding LaTeX code into Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1943 :tag "Org LaTeX"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1944 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1945
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1946 (defcustom org-format-latex-options
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1947 '(:foreground default :background default :scale 1.0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1948 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1949 :matchers ("begin" "$" "$$" "\\(" "\\["))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1950 "Options for creating images from LaTeX fragments.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1951 This is a property list with the following properties:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1952 :foreground the foreground color for images embedded in emacs, e.g. \"Black\".
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1953 `default' means use the forground of the default face.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1954 :background the background color, or \"Transparent\".
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1955 `default' means use the background of the default face.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1956 :scale a scaling factor for the size of the images
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1957 :html-foreground, :html-background, :html-scale
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1958 The same numbers for HTML export.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1959 :matchers a list indicating which matchers should be used to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1960 find LaTeX fragments. Valid members of this list are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1961 \"begin\" find environments
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1962 \"$\" find math expressions surrounded by $...$
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1963 \"$$\" find math expressions surrounded by $$....$$
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1964 \"\\(\" find math expressions surrounded by \\(...\\)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1965 \"\\ [\" find math expressions surrounded by \\ [...\\]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1966 :group 'org-latex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1967 :type 'plist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1968
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1969 (defcustom org-format-latex-header "\\documentclass{article}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1970 \\usepackage{fullpage} % do not remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1971 \\usepackage{amssymb}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1972 \\usepackage[usenames]{color}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1973 \\usepackage{amsmath}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1974 \\usepackage{latexsym}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1975 \\usepackage[mathscr]{eucal}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1976 \\pagestyle{empty} % do not remove"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1977 "The document header used for processing LaTeX fragments."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1978 :group 'org-latex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1979 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1980
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1981
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1982 (defgroup org-font-lock nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1983 "Font-lock settings for highlighting in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1984 :tag "Org Font Lock"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1985 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1986
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1987 (defcustom org-level-color-stars-only nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1988 "Non-nil means fontify only the stars in each headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1989 When nil, the entire headline is fontified.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1990 Changing it requires restart of `font-lock-mode' to become effective
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1991 also in regions already fontified."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1992 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1993 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1994
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1995 (defcustom org-hide-leading-stars nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1996 "Non-nil means, hide the first N-1 stars in a headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1997 This works by using the face `org-hide' for these stars. This
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1998 face is white for a light background, and black for a dark
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1999 background. You may have to customize the face `org-hide' to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2000 make this work.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2001 Changing it requires restart of `font-lock-mode' to become effective
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2002 also in regions already fontified.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2003 You may also set this on a per-file basis by adding one of the following
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2004 lines to the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2005
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2006 #+STARTUP: hidestars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2007 #+STARTUP: showstars"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2008 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2009 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2010
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2011 (defcustom org-fontify-done-headline nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2012 "Non-nil means, change the face of a headline if it is marked DONE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2013 Normally, only the TODO/DONE keyword indicates the state of a headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2014 When this is non-nil, the headline after the keyword is set to the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2015 `org-headline-done' as an additional indication."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2016 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2017 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2018
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2019 (defcustom org-fontify-emphasized-text t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2020 "Non-nil means fontify *bold*, /italic/ and _underlined_ text.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2021 Changing this variable requires a restart of Emacs to take effect."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2022 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2023 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2024
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2025 (defcustom org-highlight-latex-fragments-and-specials nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2026 "Non-nil means, fontify what is treated specially by the exporters."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2027 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2028 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2029
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2030 (defcustom org-hide-emphasis-markers nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2031 "Non-nil mean font-lock should hide the emphasis marker characters."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2032 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2033 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2034
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2035 (defvar org-emph-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2036 "Regular expression for matching emphasis.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2037 (defvar org-verbatim-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2038 "Regular expression for matching verbatim text.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2039 (defvar org-emphasis-regexp-components) ; defined just below
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2040 (defvar org-emphasis-alist) ; defined just below
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2041 (defun org-set-emph-re (var val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2042 "Set variable and compute the emphasis regular expression."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2043 (set var val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2044 (when (and (boundp 'org-emphasis-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2045 (boundp 'org-emphasis-regexp-components)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2046 org-emphasis-alist org-emphasis-regexp-components)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2047 (let* ((e org-emphasis-regexp-components)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2048 (pre (car e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2049 (post (nth 1 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2050 (border (nth 2 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2051 (body (nth 3 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2052 (nl (nth 4 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2053 (stacked (and nil (nth 5 e))) ; stacked is no longer allowed, forced to nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2054 (body1 (concat body "*?"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2055 (markers (mapconcat 'car org-emphasis-alist ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2056 (vmarkers (mapconcat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2057 (lambda (x) (if (eq (nth 4 x) 'verbatim) (car x) ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2058 org-emphasis-alist "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2059 ;; make sure special characters appear at the right position in the class
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2060 (if (string-match "\\^" markers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2061 (setq markers (concat (replace-match "" t t markers) "^")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2062 (if (string-match "-" markers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2063 (setq markers (concat (replace-match "" t t markers) "-")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2064 (if (string-match "\\^" vmarkers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2065 (setq vmarkers (concat (replace-match "" t t vmarkers) "^")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2066 (if (string-match "-" vmarkers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2067 (setq vmarkers (concat (replace-match "" t t vmarkers) "-")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2068 (if (> nl 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2069 (setq body1 (concat body1 "\\(?:\n" body "*?\\)\\{0,"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2070 (int-to-string nl) "\\}")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2071 ;; Make the regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2072 (setq org-emph-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2073 (concat "\\([" pre (if (and nil stacked) markers) "]\\|^\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2074 "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2075 "\\([" markers "]\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2076 "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2077 "[^" border "]\\|"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2078 "[^" border (if (and nil stacked) markers) "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2079 body1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2080 "[^" border (if (and nil stacked) markers) "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2081 "\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2082 "\\3\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2083 "\\([" post (if (and nil stacked) markers) "]\\|$\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2084 (setq org-verbatim-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2085 (concat "\\([" pre "]\\|^\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2086 "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2087 "\\([" vmarkers "]\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2088 "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2089 "[^" border "]\\|"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2090 "[^" border "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2091 body1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2092 "[^" border "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2093 "\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2094 "\\3\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2095 "\\([" post "]\\|$\\)")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2096
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2097 (defcustom org-emphasis-regexp-components
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2098 '(" \t('\"" "- \t.,:?;'\")" " \t\r\n,\"'" "." 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2099 "Components used to build the regular expression for emphasis.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2100 This is a list with 6 entries. Terminology: In an emphasis string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2101 like \" *strong word* \", we call the initial space PREMATCH, the final
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2102 space POSTMATCH, the stars MARKERS, \"s\" and \"d\" are BORDER characters
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2103 and \"trong wor\" is the body. The different components in this variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2104 specify what is allowed/forbidden in each part:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2105
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2106 pre Chars allowed as prematch. Beginning of line will be allowed too.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2107 post Chars allowed as postmatch. End of line will be allowed too.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2108 border The chars *forbidden* as border characters.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2109 body-regexp A regexp like \".\" to match a body character. Don't use
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2110 non-shy groups here, and don't allow newline here.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2111 newline The maximum number of newlines allowed in an emphasis exp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2112
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2113 Use customize to modify this, or restart Emacs after changing it."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2114 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2115 :set 'org-set-emph-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2116 :type '(list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2117 (sexp :tag "Allowed chars in pre ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2118 (sexp :tag "Allowed chars in post ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2119 (sexp :tag "Forbidden chars in border ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2120 (sexp :tag "Regexp for body ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2121 (integer :tag "number of newlines allowed")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2122 (option (boolean :tag "Stacking (DISABLED) "))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2123
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2124 (defcustom org-emphasis-alist
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2125 `(("*" bold "<b>" "</b>")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2126 ("/" italic "<i>" "</i>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2127 ("_" underline "<u>" "</u>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2128 ("=" org-code "<code>" "</code>" verbatim)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2129 ("~" org-verbatim "" "" verbatim)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2130 ("+" ,(if (featurep 'xemacs) 'org-table '(:strike-through t))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2131 "<del>" "</del>")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2132 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2133 "Special syntax for emphasized text.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2134 Text starting and ending with a special character will be emphasized, for
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2135 example *bold*, _underlined_ and /italic/. This variable sets the marker
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2136 characters, the face to be used by font-lock for highlighting in Org-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2137 Emacs buffers, and the HTML tags to be used for this.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2138 Use customize to modify this, or restart Emacs after changing it."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2139 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2140 :set 'org-set-emph-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2141 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2142 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2143 (string :tag "Marker character")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2144 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2145 (face :tag "Font-lock-face")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2146 (plist :tag "Face property list"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2147 (string :tag "HTML start tag")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2148 (string :tag "HTML end tag")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2149 (option (const verbatim)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2150
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2151 ;;; Miscellaneous options
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2152
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2153 (defgroup org-completion nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2154 "Completion in Org-mode."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2155 :tag "Org Completion"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2156 :group 'org)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2157
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2158 (defcustom org-completion-fallback-command 'hippie-expand
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2159 "The expansion command called by \\[org-complete] in normal context.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2160 Normal means, no org-mode-specific context."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2161 :group 'org-completion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2162 :type 'function)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2163
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2164 ;;; Functions and variables from ther packages
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2165 ;; Declared here to avoid compiler warnings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2166
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2167 ;; XEmacs only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2168 (defvar outline-mode-menu-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2169 (defvar outline-mode-menu-show)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2170 (defvar outline-mode-menu-hide)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2171 (defvar zmacs-regions) ; XEmacs regions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2172
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2173 ;; Emacs only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2174 (defvar mark-active)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2175
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2176 ;; Various packages
94457
79f15639a32a (calendar-absolute-from-iso, calendar-iso-from-absolute): Fix declarations.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
2177 (declare-function calendar-absolute-from-iso "cal-iso" (date))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2178 (declare-function calendar-forward-day "cal-move" (arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2179 (declare-function calendar-goto-date "cal-move" (date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2180 (declare-function calendar-goto-today "cal-move" ())
94457
79f15639a32a (calendar-absolute-from-iso, calendar-iso-from-absolute): Fix declarations.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
2181 (declare-function calendar-iso-from-absolute "cal-iso" (date))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2182 (defvar calc-embedded-close-formula)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2183 (defvar calc-embedded-open-formula)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2184 (declare-function cdlatex-tab "ext:cdlatex" ())
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2185 (declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2186 (defvar font-lock-unfontify-region-function)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2187 (declare-function iswitchb-mode "iswitchb" (&optional arg))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2188 (declare-function iswitchb-read-buffer (prompt &optional default require-match start matches-set))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2189 (defvar iswitchb-temp-buflist)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2190 (declare-function org-gnus-follow-link "org-gnus" (&optional group article))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2191 (declare-function org-agenda-skip "org-agenda" ())
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2192 (declare-function org-format-agenda-item "org-agenda"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2193 (extra txt &optional category tags dotime noprefix remove-re))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2194 (declare-function org-agenda-new-marker "org-agenda" (&optional pos))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2195 (declare-function org-agenda-change-all-lines "org-agenda"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2196 (newhead hdmarker &optional fixface))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2197 (declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2198 (declare-function org-agenda-maybe-redo "org-agenda" ())
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2199 (declare-function parse-time-string "parse-time" (string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2200 (declare-function remember "remember" (&optional initial))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2201 (declare-function remember-buffer-desc "remember" ())
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2202 (declare-function remember-finalize "remember" ())
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2203 (defvar remember-save-after-remembering)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2204 (defvar remember-data-file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2205 (defvar remember-register)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2206 (defvar remember-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2207 (defvar remember-handler-functions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2208 (defvar remember-annotation-functions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2209 (defvar texmathp-why)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2210 (declare-function speedbar-line-directory "speedbar" (&optional depth))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2211 (declare-function table--at-cell-p "table" (position &optional object at-column))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2212
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2213 (defvar w3m-current-url)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2214 (defvar w3m-current-title)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2215
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2216 (defvar org-latex-regexps)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2217
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2218 ;;; Autoload and prepare some org modules
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2219
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2220 ;; Some table stuff that needs to be defined here, because it is used
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2221 ;; by the functions setting up org-mode or checking for table context.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2222
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2223 (defconst org-table-any-line-regexp "^[ \t]*\\(|\\|\\+-[-+]\\)"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2224 "Detects an org-type or table-type table.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2225 (defconst org-table-line-regexp "^[ \t]*|"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2226 "Detects an org-type table line.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2227 (defconst org-table-dataline-regexp "^[ \t]*|[^-]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2228 "Detects an org-type table line.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2229 (defconst org-table-hline-regexp "^[ \t]*|-"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2230 "Detects an org-type table hline.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2231 (defconst org-table1-hline-regexp "^[ \t]*\\+-[-+]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2232 "Detects a table-type table hline.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2233 (defconst org-table-any-border-regexp "^[ \t]*[^|+ \t]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2234 "Searching from within a table (any type) this finds the first line
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2235 outside the table.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2236
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2237 ;; Autoload the functions in org-table.el that are needed by functions here.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2238
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2239 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2240 (org-autoload "org-table"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2241 '(org-table-align org-table-begin org-table-blank-field
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2242 org-table-convert org-table-convert-region org-table-copy-down
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2243 org-table-copy-region org-table-create
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2244 org-table-create-or-convert-from-region
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2245 org-table-create-with-table.el org-table-current-dline
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2246 org-table-cut-region org-table-delete-column org-table-edit-field
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2247 org-table-edit-formulas org-table-end org-table-eval-formula
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2248 org-table-export org-table-field-info
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2249 org-table-get-stored-formulas org-table-goto-column
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2250 org-table-hline-and-move org-table-import org-table-insert-column
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2251 org-table-insert-hline org-table-insert-row org-table-iterate
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2252 org-table-justify-field-maybe org-table-kill-row
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2253 org-table-maybe-eval-formula org-table-maybe-recalculate-line
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2254 org-table-move-column org-table-move-column-left
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2255 org-table-move-column-right org-table-move-row
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2256 org-table-move-row-down org-table-move-row-up
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2257 org-table-next-field org-table-next-row org-table-paste-rectangle
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2258 org-table-previous-field org-table-recalculate
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2259 org-table-rotate-recalc-marks org-table-sort-lines org-table-sum
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2260 org-table-toggle-coordinate-overlays
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2261 org-table-toggle-formula-debugger org-table-wrap-region
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2262 orgtbl-mode turn-on-orgtbl)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2263
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2264 (defun org-at-table-p (&optional table-type)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2265 "Return t if the cursor is inside an org-type table.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2266 If TABLE-TYPE is non-nil, also check for table.el-type tables."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2267 (if org-enable-table-editor
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2268 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2269 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2270 (looking-at (if table-type org-table-any-line-regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2271 org-table-line-regexp)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2272 nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2273 (defsubst org-table-p () (org-at-table-p))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2274
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2275 (defun org-at-table.el-p ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2276 "Return t if and only if we are at a table.el table."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2277 (and (org-at-table-p 'any)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2278 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2279 (goto-char (org-table-begin 'any))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2280 (looking-at org-table1-hline-regexp))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2281 (defun org-table-recognize-table.el ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2282 "If there is a table.el table nearby, recognize it and move into it."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2283 (if org-table-tab-recognizes-table.el
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2284 (if (org-at-table.el-p)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2285 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2286 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2287 (if (looking-at org-table-dataline-regexp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2288 nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2289 (if (looking-at org-table1-hline-regexp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2290 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2291 (beginning-of-line 2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2292 (if (looking-at org-table-any-border-regexp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2293 (beginning-of-line -1)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2294 (if (re-search-forward "|" (org-table-end t) t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2295 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2296 (require 'table)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2297 (if (table--at-cell-p (point))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2298 t
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2299 (message "recognizing table.el table...")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2300 (table-recognize-table)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2301 (message "recognizing table.el table...done")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2302 (error "This should not happen..."))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2303 t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2304 nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2305 nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2306
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2307 (defun org-at-table-hline-p ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2308 "Return t if the cursor is inside a hline in a table."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2309 (if org-enable-table-editor
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2310 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2311 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2312 (looking-at org-table-hline-regexp))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2313 nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2314
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2315 (defvar org-table-clean-did-remove-column nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2316
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2317 (defun org-table-map-tables (function)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2318 "Apply FUNCTION to the start of all tables in the buffer."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2319 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2320 (save-restriction
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2321 (widen)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2322 (goto-char (point-min))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2323 (while (re-search-forward org-table-any-line-regexp nil t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2324 (message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2325 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2326 (if (looking-at org-table-line-regexp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2327 (save-excursion (funcall function)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2328 (re-search-forward org-table-any-border-regexp nil 1))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2329 (message "Mapping tables: done"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2330
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2331 ;; Declare and autoload functions from org-exp.el
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2332
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2333 (declare-function org-default-export-plist "org-exp")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2334 (declare-function org-infile-export-plist "org-exp")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2335 (declare-function org-get-current-options "org-exp")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2336 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2337 (org-autoload "org-exp"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2338 '(org-export org-export-as-ascii org-export-visible
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2339 org-insert-export-options-template org-export-as-html-and-open
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2340 org-export-as-html-batch org-export-as-html-to-buffer
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2341 org-replace-region-by-html org-export-region-as-html
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2342 org-export-as-html org-export-icalendar-this-file
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2343 org-export-icalendar-all-agenda-files
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2344 org-export-icalendar-combine-agenda-files org-export-as-xoxo)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2345
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2346 ;; Declare and autoload functions from org-exp.el
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2347
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2348 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2349 (org-autoload "org-exp"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2350 '(org-agenda org-agenda-list org-search-view
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2351 org-todo-list org-tags-view org-agenda-list-stuck-projects
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2352 org-diary org-agenda-to-appt)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2353
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2354 ;; Autoload org-remember
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2355
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2356 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2357 (org-autoload "org-remember"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2358 '(org-remember-insinuate org-remember-annotation
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2359 org-remember-apply-template org-remember org-remember-handler)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2360
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2361 ;; Autoload org-clock.el
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2362
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2363 (defvar org-clock-marker (make-marker)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2364 "Marker recording the last clock-in.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2365
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2366 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2367 (org-autoload
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2368 "org-clock"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2369 '(org-clock-in org-clock-out org-clock-cancel
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2370 org-clock-goto org-clock-sum org-clock-display
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2371 org-remove-clock-overlays org-clock-report
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2372 org-clocktable-shift org-dblock-write:clocktable
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2373 org-get-clocktable)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2374
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2375 (defun org-clock-update-time-maybe ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2376 "If this is a CLOCK line, update it and return t.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2377 Otherwise, return nil."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2378 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2379 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2380 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2381 (skip-chars-forward " \t")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2382 (when (looking-at org-clock-string)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2383 (let ((re (concat "[ \t]*" org-clock-string
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2384 " *[[<]\\([^]>]+\\)[]>]-+[[<]\\([^]>]+\\)[]>]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2385 "\\([ \t]*=>.*\\)?"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2386 ts te h m s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2387 (if (not (looking-at re))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2388 nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2389 (and (match-end 3) (delete-region (match-beginning 3) (match-end 3)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2390 (end-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2391 (setq ts (match-string 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2392 te (match-string 2))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2393 (setq s (- (time-to-seconds
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2394 (apply 'encode-time (org-parse-time-string te)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2395 (time-to-seconds
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2396 (apply 'encode-time (org-parse-time-string ts))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2397 h (floor (/ s 3600))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2398 s (- s (* 3600 h))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2399 m (floor (/ s 60))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2400 s (- s (* 60 s)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2401 (insert " => " (format "%2d:%02d" h m))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2402 t)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2403
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2404 (defun org-check-running-clock ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2405 "Check if the current buffer contains the running clock.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2406 If yes, offer to stop it and to save the buffer with the changes."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2407 (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2408 (y-or-n-p (format "Clock-out in buffer %s before killing it? "
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2409 (buffer-name))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2410 (org-clock-out)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2411 (when (y-or-n-p "Save changed buffer?")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2412 (save-buffer))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2413
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2414 (defun org-clocktable-try-shift (dir n)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2415 "Check if this line starts a clock table, if yes, shift the time block."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2416 (when (org-match-line "#\\+BEGIN: clocktable\\>")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2417 (org-clocktable-shift dir n)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2418
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2419 ;; Autoload archiving code
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2420 ;; The stuff that is needed for cycling and tags has to be defined here.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2421
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2422 (defgroup org-archive nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2423 "Options concerning archiving in Org-mode."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2424 :tag "Org Archive"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2425 :group 'org-structure)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2426
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2427 (defcustom org-archive-location "%s_archive::"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2428 "The location where subtrees should be archived.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2429
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2430 Otherwise, the value of this variable is a string, consisting of two
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2431 parts, separated by a double-colon.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2432
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2433 The first part is a file name - when omitted, archiving happens in the same
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2434 file. %s will be replaced by the current file name (without directory part).
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2435 Archiving to a different file is useful to keep archived entries from
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2436 contributing to the Org-mode Agenda.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2437
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2438 The part after the double colon is a headline. The archived entries will be
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2439 filed under that headline. When omitted, the subtrees are simply filed away
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2440 at the end of the file, as top-level entries.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2441
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2442 Here are a few examples:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2443 \"%s_archive::\"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2444 If the current file is Projects.org, archive in file
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2445 Projects.org_archive, as top-level trees. This is the default.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2446
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2447 \"::* Archived Tasks\"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2448 Archive in the current file, under the top-level headline
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2449 \"* Archived Tasks\".
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2450
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2451 \"~/org/archive.org::\"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2452 Archive in file ~/org/archive.org (absolute path), as top-level trees.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2453
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2454 \"basement::** Finished Tasks\"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2455 Archive in file ./basement (relative path), as level 3 trees
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2456 below the level 2 heading \"** Finished Tasks\".
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2457
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2458 You may set this option on a per-file basis by adding to the buffer a
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2459 line like
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2460
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2461 #+ARCHIVE: basement::** Finished Tasks
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2462
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2463 You may also define it locally for a subtree by setting an ARCHIVE property
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2464 in the entry. If such a property is found in an entry, or anywhere up
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2465 the hierarchy, it will be used."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2466 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2467 :type 'string)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2468
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2469 (defcustom org-archive-tag "ARCHIVE"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2470 "The tag that marks a subtree as archived.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2471 An archived subtree does not open during visibility cycling, and does
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2472 not contribute to the agenda listings.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2473 After changing this, font-lock must be restarted in the relevant buffers to
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2474 get the proper fontification."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2475 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2476 :group 'org-keywords
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2477 :type 'string)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2478
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2479 (defcustom org-agenda-skip-archived-trees t
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2480 "Non-nil means, the agenda will skip any items located in archived trees.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2481 An archived tree is a tree marked with the tag ARCHIVE."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2482 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2483 :group 'org-agenda-skip
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2484 :type 'boolean)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2485
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2486 (defcustom org-cycle-open-archived-trees nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2487 "Non-nil means, `org-cycle' will open archived trees.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2488 An archived tree is a tree marked with the tag ARCHIVE.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2489 When nil, archived trees will stay folded. You can still open them with
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2490 normal outline commands like `show-all', but not with the cycling commands."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2491 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2492 :group 'org-cycle
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2493 :type 'boolean)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2494
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2495 (defcustom org-sparse-tree-open-archived-trees nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2496 "Non-nil means sparse tree construction shows matches in archived trees.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2497 When nil, matches in these trees are highlighted, but the trees are kept in
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2498 collapsed state."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2499 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2500 :group 'org-sparse-trees
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2501 :type 'boolean)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2502
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2503 (defun org-cycle-hide-archived-subtrees (state)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2504 "Re-hide all archived subtrees after a visibility state change."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2505 (when (and (not org-cycle-open-archived-trees)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2506 (not (memq state '(overview folded))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2507 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2508 (let* ((globalp (memq state '(contents all)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2509 (beg (if globalp (point-min) (point)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2510 (end (if globalp (point-max) (org-end-of-subtree t))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2511 (org-hide-archived-subtrees beg end)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2512 (goto-char beg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2513 (if (looking-at (concat ".*:" org-archive-tag ":"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2514 (message "%s" (substitute-command-keys
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2515 "Subtree is archived and stays closed. Use \\[org-force-cycle-archived] to cycle it anyway.")))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2516
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2517 (defun org-force-cycle-archived ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2518 "Cycle subtree even if it is archived."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2519 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2520 (setq this-command 'org-cycle)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2521 (let ((org-cycle-open-archived-trees t))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2522 (call-interactively 'org-cycle)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2523
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2524 (defun org-hide-archived-subtrees (beg end)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2525 "Re-hide all archived subtrees after a visibility state change."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2526 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2527 (let* ((re (concat ":" org-archive-tag ":")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2528 (goto-char beg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2529 (while (re-search-forward re end t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2530 (and (org-on-heading-p) (hide-subtree))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2531 (org-end-of-subtree t)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2532
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2533 (defalias 'org-advertized-archive-subtree 'org-archive-subtree)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2534
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2535 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2536 (org-autoload "org-archive"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2537 '(org-add-archive-files org-archive-subtree
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2538 org-archive-to-archive-sibling org-toggle-archive-tag)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2539
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2540 ;; Autoload Column View Code
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2541
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2542 (declare-function org-columns-number-to-string "org-colview")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2543 (declare-function org-columns-get-format-and-top-level "org-colview")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2544 (declare-function org-columns-compute "org-colview")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2545
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2546 (org-autoload (if (featurep 'xemacs) "org-colview-xemacs" "org-colview")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2547 '(org-columns-number-to-string org-columns-get-format-and-top-level
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2548 org-columns-compute org-agenda-columns org-columns-remove-overlays
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2549 org-columns org-insert-columns-dblock))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2550
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2551 ;;; Variables for pre-computed regular expressions, all buffer local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2552
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2553 (defvar org-drawer-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2554 "Matches first line of a hidden block.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2555 (make-variable-buffer-local 'org-drawer-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2556 (defvar org-todo-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2557 "Matches any of the TODO state keywords.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2558 (make-variable-buffer-local 'org-todo-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2559 (defvar org-not-done-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2560 "Matches any of the TODO state keywords except the last one.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2561 (make-variable-buffer-local 'org-not-done-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2562 (defvar org-todo-line-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2563 "Matches a headline and puts TODO state into group 2 if present.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2564 (make-variable-buffer-local 'org-todo-line-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2565 (defvar org-complex-heading-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2566 "Matches a headline and puts everything into groups:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2567 group 1: the stars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2568 group 2: The todo keyword, maybe
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2569 group 3: Priority cookie
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2570 group 4: True headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2571 group 5: Tags")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2572 (make-variable-buffer-local 'org-complex-heading-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2573 (defvar org-todo-line-tags-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2574 "Matches a headline and puts TODO state into group 2 if present.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2575 Also put tags into group 4 if tags are present.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2576 (make-variable-buffer-local 'org-todo-line-tags-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2577 (defvar org-nl-done-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2578 "Matches newline followed by a headline with the DONE keyword.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2579 (make-variable-buffer-local 'org-nl-done-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2580 (defvar org-looking-at-done-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2581 "Matches the DONE keyword a point.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2582 (make-variable-buffer-local 'org-looking-at-done-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2583 (defvar org-ds-keyword-length 12
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2584 "Maximum length of the Deadline and SCHEDULED keywords.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2585 (make-variable-buffer-local 'org-ds-keyword-length)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2586 (defvar org-deadline-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2587 "Matches the DEADLINE keyword.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2588 (make-variable-buffer-local 'org-deadline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2589 (defvar org-deadline-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2590 "Matches the DEADLINE keyword together with a time stamp.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2591 (make-variable-buffer-local 'org-deadline-time-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2592 (defvar org-deadline-line-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2593 "Matches the DEADLINE keyword and the rest of the line.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2594 (make-variable-buffer-local 'org-deadline-line-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2595 (defvar org-scheduled-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2596 "Matches the SCHEDULED keyword.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2597 (make-variable-buffer-local 'org-scheduled-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2598 (defvar org-scheduled-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2599 "Matches the SCHEDULED keyword together with a time stamp.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2600 (make-variable-buffer-local 'org-scheduled-time-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2601 (defvar org-closed-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2602 "Matches the CLOSED keyword together with a time stamp.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2603 (make-variable-buffer-local 'org-closed-time-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2604
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2605 (defvar org-keyword-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2606 "Matches any of the 4 keywords, together with the time stamp.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2607 (make-variable-buffer-local 'org-keyword-time-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2608 (defvar org-keyword-time-not-clock-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2609 "Matches any of the 3 keywords, together with the time stamp.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2610 (make-variable-buffer-local 'org-keyword-time-not-clock-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2611 (defvar org-maybe-keyword-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2612 "Matches a timestamp, possibly preceeded by a keyword.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2613 (make-variable-buffer-local 'org-maybe-keyword-time-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2614 (defvar org-planning-or-clock-line-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2615 "Matches a line with planning or clock info.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2616 (make-variable-buffer-local 'org-planning-or-clock-line-re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2617
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2618 (defconst org-plain-time-of-day-regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2619 (concat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2620 "\\(\\<[012]?[0-9]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2621 "\\(\\(:\\([0-5][0-9]\\([AaPp][Mm]\\)?\\)\\)\\|\\([AaPp][Mm]\\)\\)\\>\\)"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2622 "\\(--?"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2623 "\\(\\<[012]?[0-9]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2624 "\\(\\(:\\([0-5][0-9]\\([AaPp][Mm]\\)?\\)\\)\\|\\([AaPp][Mm]\\)\\)\\>\\)"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2625 "\\)?")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2626 "Regular expression to match a plain time or time range.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2627 Examples: 11:45 or 8am-13:15 or 2:45-2:45pm. After a match, the following
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2628 groups carry important information:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2629 0 the full match
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2630 1 the first time, range or not
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2631 8 the second time, if it is a range.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2632
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2633 (defconst org-plain-time-extension-regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2634 (concat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2635 "\\(\\<[012]?[0-9]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2636 "\\(\\(:\\([0-5][0-9]\\([AaPp][Mm]\\)?\\)\\)\\|\\([AaPp][Mm]\\)\\)\\>\\)"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2637 "\\+\\([0-9]+\\)\\(:\\([0-5][0-9]\\)\\)?")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2638 "Regular expression to match a time range like 13:30+2:10 = 13:30-15:40.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2639 Examples: 11:45 or 8am-13:15 or 2:45-2:45pm. After a match, the following
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2640 groups carry important information:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2641 0 the full match
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2642 7 hours of duration
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2643 9 minutes of duration")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2644
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2645 (defconst org-stamp-time-of-day-regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2646 (concat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2647 "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} +\\sw+ +\\)"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2648 "\\([012][0-9]:[0-5][0-9]\\(-\\([012][0-9]:[0-5][0-9]\\)\\)?[^\n\r>]*?\\)>"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2649 "\\(--?"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2650 "<\\1\\([012][0-9]:[0-5][0-9]\\)>\\)?")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2651 "Regular expression to match a timestamp time or time range.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2652 After a match, the following groups carry important information:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2653 0 the full match
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2654 1 date plus weekday, for backreferencing to make sure both times on same day
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2655 2 the first time, range or not
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2656 4 the second time, if it is a range.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2657
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2658 (defconst org-startup-options
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2659 '(("fold" org-startup-folded t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2660 ("overview" org-startup-folded t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2661 ("nofold" org-startup-folded nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2662 ("showall" org-startup-folded nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2663 ("content" org-startup-folded content)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2664 ("hidestars" org-hide-leading-stars t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2665 ("showstars" org-hide-leading-stars nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2666 ("odd" org-odd-levels-only t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2667 ("oddeven" org-odd-levels-only nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2668 ("align" org-startup-align-all-tables t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2669 ("noalign" org-startup-align-all-tables nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2670 ("customtime" org-display-custom-times t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2671 ("logdone" org-log-done time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2672 ("lognotedone" org-log-done note)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2673 ("nologdone" org-log-done nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2674 ("lognoteclock-out" org-log-note-clock-out t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2675 ("nolognoteclock-out" org-log-note-clock-out nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2676 ("logrepeat" org-log-repeat state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2677 ("lognoterepeat" org-log-repeat note)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2678 ("nologrepeat" org-log-repeat nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2679 ("constcgs" constants-unit-system cgs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2680 ("constSI" constants-unit-system SI))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2681 "Variable associated with STARTUP options for org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2682 Each element is a list of three items: The startup options as written
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2683 in the #+STARTUP line, the corresponding variable, and the value to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2684 set this variable to if the option is found. An optional forth element PUSH
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2685 means to push this value onto the list in the variable.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2686
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2687 (defun org-set-regexps-and-options ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2688 "Precompute regular expressions for current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2689 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2690 (org-set-local 'org-todo-kwd-alist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2691 (org-set-local 'org-todo-key-alist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2692 (org-set-local 'org-todo-key-trigger nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2693 (org-set-local 'org-todo-keywords-1 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2694 (org-set-local 'org-done-keywords nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2695 (org-set-local 'org-todo-heads nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2696 (org-set-local 'org-todo-sets nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2697 (org-set-local 'org-todo-log-states nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2698 (let ((re (org-make-options-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2699 '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "COLUMNS"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2700 "STARTUP" "ARCHIVE" "TAGS" "LINK" "PRIORITIES"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2701 "CONSTANTS" "PROPERTY" "DRAWERS")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2702 (splitre "[ \t]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2703 kwds kws0 kwsa key log value cat arch tags const links hw dws
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2704 tail sep kws1 prio props drawers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2705 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2706 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2707 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2708 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2709 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2710 (setq key (match-string 1) value (org-match-string-no-properties 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2711 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2712 ((equal key "CATEGORY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2713 (if (string-match "[ \t]+$" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2714 (setq value (replace-match "" t t value)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2715 (setq cat value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2716 ((member key '("SEQ_TODO" "TODO"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2717 (push (cons 'sequence (org-split-string value splitre)) kwds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2718 ((equal key "TYP_TODO")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2719 (push (cons 'type (org-split-string value splitre)) kwds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2720 ((equal key "TAGS")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2721 (setq tags (append tags (org-split-string value splitre))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2722 ((equal key "COLUMNS")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2723 (org-set-local 'org-columns-default-format value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2724 ((equal key "LINK")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2725 (when (string-match "^\\(\\S-+\\)[ \t]+\\(.+\\)" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2726 (push (cons (match-string 1 value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2727 (org-trim (match-string 2 value)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2728 links)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2729 ((equal key "PRIORITIES")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2730 (setq prio (org-split-string value " +")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2731 ((equal key "PROPERTY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2732 (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2733 (push (cons (match-string 1 value) (match-string 2 value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2734 props)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2735 ((equal key "DRAWERS")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2736 (setq drawers (org-split-string value splitre)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2737 ((equal key "CONSTANTS")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2738 (setq const (append const (org-split-string value splitre))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2739 ((equal key "STARTUP")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2740 (let ((opts (org-split-string value splitre))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2741 l var val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2742 (while (setq l (pop opts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2743 (when (setq l (assoc l org-startup-options))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2744 (setq var (nth 1 l) val (nth 2 l))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2745 (if (not (nth 3 l))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2746 (set (make-local-variable var) val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2747 (if (not (listp (symbol-value var)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2748 (set (make-local-variable var) nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2749 (set (make-local-variable var) (symbol-value var))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2750 (add-to-list var val))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2751 ((equal key "ARCHIVE")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2752 (string-match " *$" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2753 (setq arch (replace-match "" t t value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2754 (remove-text-properties 0 (length arch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2755 '(face t fontified t) arch)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2756 )))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2757 (when cat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2758 (org-set-local 'org-category (intern cat))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2759 (push (cons "CATEGORY" cat) props))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2760 (when prio
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2761 (if (< (length prio) 3) (setq prio '("A" "C" "B")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2762 (setq prio (mapcar 'string-to-char prio))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2763 (org-set-local 'org-highest-priority (nth 0 prio))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2764 (org-set-local 'org-lowest-priority (nth 1 prio))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2765 (org-set-local 'org-default-priority (nth 2 prio)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2766 (and props (org-set-local 'org-local-properties (nreverse props)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2767 (and drawers (org-set-local 'org-drawers drawers))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2768 (and arch (org-set-local 'org-archive-location arch))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2769 (and links (setq org-link-abbrev-alist-local (nreverse links)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2770 ;; Process the TODO keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2771 (unless kwds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2772 ;; Use the global values as if they had been given locally.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2773 (setq kwds (default-value 'org-todo-keywords))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2774 (if (stringp (car kwds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2775 (setq kwds (list (cons org-todo-interpretation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2776 (default-value 'org-todo-keywords)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2777 (setq kwds (reverse kwds)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2778 (setq kwds (nreverse kwds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2779 (let (inter kws kw)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2780 (while (setq kws (pop kwds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2781 (setq inter (pop kws) sep (member "|" kws)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2782 kws0 (delete "|" (copy-sequence kws))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2783 kwsa nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2784 kws1 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2785 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2786 ;; 1 2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2787 (if (string-match "^\\(.*?\\)\\(?:(\\([^!@/]\\)?.*?)\\)?$" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2788 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2789 (setq kw (match-string 1 x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2790 key (and (match-end 2) (match-string 2 x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2791 log (org-extract-log-state-settings x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2792 (push (cons kw (and key (string-to-char key))) kwsa)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2793 (and log (push log org-todo-log-states))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2794 kw)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2795 (error "Invalid TODO keyword %s" x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2796 kws0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2797 kwsa (if kwsa (append '((:startgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2798 (nreverse kwsa)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2799 '((:endgroup))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2800 hw (car kws1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2801 dws (if sep (org-remove-keyword-keys (cdr sep)) (last kws1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2802 tail (list inter hw (car dws) (org-last dws)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2803 (add-to-list 'org-todo-heads hw 'append)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2804 (push kws1 org-todo-sets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2805 (setq org-done-keywords (append org-done-keywords dws nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2806 (setq org-todo-key-alist (append org-todo-key-alist kwsa))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2807 (mapc (lambda (x) (push (cons x tail) org-todo-kwd-alist)) kws1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2808 (setq org-todo-keywords-1 (append org-todo-keywords-1 kws1 nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2809 (setq org-todo-sets (nreverse org-todo-sets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2810 org-todo-kwd-alist (nreverse org-todo-kwd-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2811 org-todo-key-trigger (delq nil (mapcar 'cdr org-todo-key-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2812 org-todo-key-alist (org-assign-fast-keys org-todo-key-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2813 ;; Process the constants
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2814 (when const
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2815 (let (e cst)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2816 (while (setq e (pop const))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2817 (if (string-match "^\\([a-zA-Z0][_a-zA-Z0-9]*\\)=\\(.*\\)" e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2818 (push (cons (match-string 1 e) (match-string 2 e)) cst)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2819 (setq org-table-formula-constants-local cst)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2820
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2821 ;; Process the tags.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2822 (when tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2823 (let (e tgs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2824 (while (setq e (pop tags))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2825 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2826 ((equal e "{") (push '(:startgroup) tgs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2827 ((equal e "}") (push '(:endgroup) tgs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2828 ((string-match (org-re "^\\([[:alnum:]_@]+\\)(\\(.\\))$") e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2829 (push (cons (match-string 1 e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2830 (string-to-char (match-string 2 e)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2831 tgs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2832 (t (push (list e) tgs))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2833 (org-set-local 'org-tag-alist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2834 (while (setq e (pop tgs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2835 (or (and (stringp (car e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2836 (assoc (car e) org-tag-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2837 (push e org-tag-alist))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2838
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2839 ;; Compute the regular expressions and other local variables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2840 (if (not org-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2841 (setq org-done-keywords (list (org-last org-todo-keywords-1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2842 (setq org-ds-keyword-length (+ 2 (max (length org-deadline-string)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2843 (length org-scheduled-string)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2844 (length org-clock-string)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2845 (length org-closed-string)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2846 org-drawer-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2847 (concat "^[ \t]*:\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2848 (mapconcat 'regexp-quote org-drawers "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2849 "\\):[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2850 org-not-done-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2851 (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2852 org-todo-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2853 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2854 "\\|") "\\)\\>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2855 org-not-done-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2856 (concat "\\<\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2857 (mapconcat 'regexp-quote org-not-done-keywords "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2858 "\\)\\>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2859 org-todo-line-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2860 (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2861 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2862 "\\)\\>\\)?[ \t]*\\(.*\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2863 org-complex-heading-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2864 (concat "^\\(\\*+\\)\\(?:[ \t]+\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2865 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2866 "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2867 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2868 org-nl-done-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2869 (concat "\n\\*+[ \t]+"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2870 "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2871 "\\)" "\\>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2872 org-todo-line-tags-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2873 (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2874 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2875 (org-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2876 "\\)\\>\\)? *\\(.*?\\([ \t]:[[:alnum:]:_@]+:[ \t]*\\)?$\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2877 org-looking-at-done-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2878 (concat "^" "\\(?:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2879 (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2880 "\\>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2881 org-deadline-regexp (concat "\\<" org-deadline-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2882 org-deadline-time-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2883 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2884 org-deadline-line-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2885 (concat "\\<\\(" org-deadline-string "\\).*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2886 org-scheduled-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2887 (concat "\\<" org-scheduled-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2888 org-scheduled-time-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2889 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2890 org-closed-time-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2891 (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2892 org-keyword-time-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2893 (concat "\\<\\(" org-scheduled-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2894 "\\|" org-deadline-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2895 "\\|" org-closed-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2896 "\\|" org-clock-string "\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2897 " *[[<]\\([^]>]+\\)[]>]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2898 org-keyword-time-not-clock-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2899 (concat "\\<\\(" org-scheduled-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2900 "\\|" org-deadline-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2901 "\\|" org-closed-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2902 "\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2903 " *[[<]\\([^]>]+\\)[]>]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2904 org-maybe-keyword-time-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2905 (concat "\\(\\<\\(" org-scheduled-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2906 "\\|" org-deadline-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2907 "\\|" org-closed-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2908 "\\|" org-clock-string "\\)\\)?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2909 " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2910 org-planning-or-clock-line-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2911 (concat "\\(?:^[ \t]*\\(" org-scheduled-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2912 "\\|" org-deadline-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2913 "\\|" org-closed-string "\\|" org-clock-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2914 "\\)\\>\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2915 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2916 (org-compute-latex-and-specials-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2917 (org-set-font-lock-defaults)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2918
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2919 (defun org-extract-log-state-settings (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2920 "Extract the log state setting from a TODO keyword string.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2921 This will extract info from a string like \"WAIT(w@/!)\"."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2922 (let (kw key log1 log2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2923 (when (string-match "^\\(.*?\\)\\(?:(\\([^!@/]\\)?\\([!@]\\)?\\(?:/\\([!@]\\)\\)?)\\)?$" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2924 (setq kw (match-string 1 x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2925 key (and (match-end 2) (match-string 2 x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2926 log1 (and (match-end 3) (match-string 3 x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2927 log2 (and (match-end 4) (match-string 4 x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2928 (and (or log1 log2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2929 (list kw
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2930 (and log1 (if (equal log1 "!") 'time 'note))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2931 (and log2 (if (equal log2 "!") 'time 'note)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2932
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2933 (defun org-remove-keyword-keys (list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2934 "Remove a pair of parenthesis at the end of each string in LIST."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2935 (mapcar (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2936 (if (string-match "(.*)$" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2937 (substring x 0 (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2938 x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2939 list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2940
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2941 ;; FIXME: this could be done much better, using second characters etc.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2942 (defun org-assign-fast-keys (alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2943 "Assign fast keys to a keyword-key alist.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2944 Respect keys that are already there."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2945 (let (new e k c c1 c2 (char ?a))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2946 (while (setq e (pop alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2947 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2948 ((equal e '(:startgroup)) (push e new))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2949 ((equal e '(:endgroup)) (push e new))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2950 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2951 (setq k (car e) c2 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2952 (if (cdr e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2953 (setq c (cdr e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2954 ;; automatically assign a character.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2955 (setq c1 (string-to-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2956 (downcase (substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2957 k (if (= (string-to-char k) ?@) 1 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2958 (if (or (rassoc c1 new) (rassoc c1 alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2959 (while (or (rassoc char new) (rassoc char alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2960 (setq char (1+ char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2961 (setq c2 c1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2962 (setq c (or c2 char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2963 (push (cons k c) new))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2964 (nreverse new)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2965
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2966 ;;; Some variables used in various places
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2967
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2968 (defvar org-window-configuration nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2969 "Used in various places to store a window configuration.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2970 (defvar org-finish-function nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2971 "Function to be called when `C-c C-c' is used.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2972 This is for getting out of special buffers like remember.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2973
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2974
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2975 ;; FIXME: Occasionally check by commenting these, to make sure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2976 ;; no other functions uses these, forgetting to let-bind them.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2977 (defvar entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2978 (defvar state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2979 (defvar last-state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2980 (defvar date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2981 (defvar description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2982
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2983 ;; Defined somewhere in this file, but used before definition.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2984 (defvar org-html-entities)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2985 (defvar org-struct-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2986 (defvar org-org-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2987 (defvar org-tbl-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2988 (defvar org-agenda-keymap)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2989
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2990 ;;;; Define the Org-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2991
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2992 (if (and (not (keymapp outline-mode-map)) (featurep 'allout))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2993 (error "Conflict with outdated version of allout.el. Load org.el before allout.el, or ugrade to newer allout, for example by switching to Emacs 22."))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2994
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2995
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2996 ;; We use a before-change function to check if a table might need
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2997 ;; an update.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2998 (defvar org-table-may-need-update t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2999 "Indicates that a table might need an update.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3000 This variable is set by `org-before-change-function'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3001 `org-table-align' sets it back to nil.")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3002 (defun org-before-change-function (beg end)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3003 "Every change indicates that a table might need an update."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3004 (setq org-table-may-need-update t))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3005 (defvar org-mode-map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3006 (defvar org-mode-hook nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3007 (defvar org-inhibit-startup nil) ; Dynamically-scoped param.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3008 (defvar org-agenda-keep-modes nil) ; Dynamically-scoped param.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3009 (defvar org-table-buffer-is-an nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3010 (defconst org-outline-regexp "\\*+ ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3011
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3012 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3013 (define-derived-mode org-mode outline-mode "Org"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3014 "Outline-based notes management and organizer, alias
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3015 \"Carsten's outline-mode for keeping track of everything.\"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3016
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3017 Org-mode develops organizational tasks around a NOTES file which
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3018 contains information about projects as plain text. Org-mode is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3019 implemented on top of outline-mode, which is ideal to keep the content
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3020 of large files well structured. It supports ToDo items, deadlines and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3021 time stamps, which magically appear in the diary listing of the Emacs
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3022 calendar. Tables are easily created with a built-in table editor.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3023 Plain text URL-like links connect to websites, emails (VM), Usenet
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3024 messages (Gnus), BBDB entries, and any files related to the project.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3025 For printing and sharing of notes, an Org-mode file (or a part of it)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3026 can be exported as a structured ASCII or HTML file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3027
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3028 The following commands are available:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3029
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3030 \\{org-mode-map}"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3031
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3032 ;; Get rid of Outline menus, they are not needed
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3033 ;; Need to do this here because define-derived-mode sets up
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3034 ;; the keymap so late. Still, it is a waste to call this each time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3035 ;; we switch another buffer into org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3036 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3037 (when (boundp 'outline-mode-menu-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3038 ;; Assume this is Greg's port, it used easymenu
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3039 (easy-menu-remove outline-mode-menu-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3040 (easy-menu-remove outline-mode-menu-show)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3041 (easy-menu-remove outline-mode-menu-hide))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3042 (define-key org-mode-map [menu-bar headings] 'undefined)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3043 (define-key org-mode-map [menu-bar hide] 'undefined)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3044 (define-key org-mode-map [menu-bar show] 'undefined))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3045
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3046 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3047 (easy-menu-add org-org-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3048 (easy-menu-add org-tbl-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3049 (org-install-agenda-files-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3050 (if org-descriptive-links (org-add-to-invisibility-spec '(org-link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3051 (org-add-to-invisibility-spec '(org-cwidth))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3052 (when (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3053 (org-set-local 'line-move-ignore-invisible t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3054 (org-set-local 'outline-regexp org-outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3055 (org-set-local 'outline-level 'org-outline-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3056 (when (and org-ellipsis
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3057 (fboundp 'set-display-table-slot) (boundp 'buffer-display-table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3058 (fboundp 'make-glyph-code))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3059 (unless org-display-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3060 (setq org-display-table (make-display-table)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3061 (set-display-table-slot
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3062 org-display-table 4
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3063 (vconcat (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3064 (lambda (c) (make-glyph-code c (and (not (stringp org-ellipsis))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3065 org-ellipsis)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3066 (if (stringp org-ellipsis) org-ellipsis "..."))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3067 (setq buffer-display-table org-display-table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3068 (org-set-regexps-and-options)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3069 ;; Calc embedded
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3070 (org-set-local 'calc-embedded-open-mode "# ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3071 (modify-syntax-entry ?# "<")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3072 (modify-syntax-entry ?@ "w")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3073 (if org-startup-truncated (setq truncate-lines t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3074 (org-set-local 'font-lock-unfontify-region-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3075 'org-unfontify-region)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3076 ;; Activate before-change-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3077 (org-set-local 'org-table-may-need-update t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3078 (org-add-hook 'before-change-functions 'org-before-change-function nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3079 'local)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3080 ;; Check for running clock before killing a buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3081 (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3082 ;; Paragraphs and auto-filling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3083 (org-set-autofill-regexps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3084 (setq indent-line-function 'org-indent-line-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3085 (org-update-radio-target-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3086
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3087 ;; Comment characters
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3088 ; (org-set-local 'comment-start "#") ;; FIXME: this breaks wrapping
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3089 (org-set-local 'comment-padding " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3090
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3091 ;; Align options lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3092 (org-set-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3093 'align-mode-rules-list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3094 '((org-in-buffer-settings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3095 (regexp . "^#\\+[A-Z_]+:\\(\\s-*\\)\\S-+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3096 (modes . '(org-mode)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3097
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3098 ;; Imenu
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3099 (org-set-local 'imenu-create-index-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3100 'org-imenu-get-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3101
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3102 ;; Make isearch reveal context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3103 (if (or (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3104 (not (boundp 'outline-isearch-open-invisible-function)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3105 ;; Emacs 21 and XEmacs make use of the hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3106 (org-add-hook 'isearch-mode-end-hook 'org-isearch-end 'append 'local)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3107 ;; Emacs 22 deals with this through a special variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3108 (org-set-local 'outline-isearch-open-invisible-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3109 (lambda (&rest ignore) (org-show-context 'isearch))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3110
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3111 ;; If empty file that did not turn on org-mode automatically, make it to.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3112 (if (and org-insert-mode-line-in-empty-file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3113 (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3114 (= (point-min) (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3115 (insert "# -*- mode: org -*-\n\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3116
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3117 (unless org-inhibit-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3118 (when org-startup-align-all-tables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3119 (let ((bmp (buffer-modified-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3120 (org-table-map-tables 'org-table-align)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3121 (set-buffer-modified-p bmp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3122 (org-cycle-hide-drawers 'all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3123 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3124 ((eq org-startup-folded t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3125 (org-cycle '(4)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3126 ((eq org-startup-folded 'content)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3127 (let ((this-command 'org-cycle) (last-command 'org-cycle))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3128 (org-cycle '(4)) (org-cycle '(4)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3129
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3130 (put 'org-mode 'flyspell-mode-predicate 'org-mode-flyspell-verify)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3131
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3132 (defun org-current-time ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3133 "Current time, possibly rounded to `org-time-stamp-rounding-minutes'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3134 (if (> (car org-time-stamp-rounding-minutes) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3135 (let ((r (car org-time-stamp-rounding-minutes))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3136 (time (decode-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3137 (apply 'encode-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3138 (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3139 (nthcdr 2 time))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3140 (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3142 ;;;; Font-Lock stuff, including the activators
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3143
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3144 (defvar org-mouse-map (make-sparse-keymap))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3145 (org-defkey org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3146 (if (featurep 'xemacs) [button2] [mouse-2]) 'org-open-at-mouse)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3147 (org-defkey org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3148 (if (featurep 'xemacs) [button3] [mouse-3]) 'org-find-file-at-mouse)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3149 (when org-mouse-1-follows-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3150 (org-defkey org-mouse-map [follow-link] 'mouse-face))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3151 (when org-tab-follows-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3152 (org-defkey org-mouse-map [(tab)] 'org-open-at-point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3153 (org-defkey org-mouse-map "\C-i" 'org-open-at-point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3154 (when org-return-follows-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3155 (org-defkey org-mouse-map [(return)] 'org-open-at-point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3156 (org-defkey org-mouse-map "\C-m" 'org-open-at-point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3157
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3158 (require 'font-lock)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3159
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3160 (defconst org-non-link-chars "]\t\n\r<>")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3161 (defvar org-link-types '("http" "https" "ftp" "mailto" "file" "news"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3162 "shell" "elisp"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3163 (defvar org-link-types-re nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3164 "Matches a link that has a url-like prefix like \"http:\"")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3165 (defvar org-link-re-with-space nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3166 "Matches a link with spaces, optional angular brackets around it.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3167 (defvar org-link-re-with-space2 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3168 "Matches a link with spaces, optional angular brackets around it.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3169 (defvar org-angle-link-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3170 "Matches link with angular brackets, spaces are allowed.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3171 (defvar org-plain-link-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3172 "Matches plain link, without spaces.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3173 (defvar org-bracket-link-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3174 "Matches a link in double brackets.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3175 (defvar org-bracket-link-analytic-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3176 "Regular expression used to analyze links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3177 Here is what the match groups contain after a match:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3178 1: http:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3179 2: http
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3180 3: path
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3181 4: [desc]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3182 5: desc")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3183 (defvar org-any-link-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3184 "Regular expression matching any link.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3185
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3186 (defun org-make-link-regexps ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3187 "Update the link regular expressions.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3188 This should be called after the variable `org-link-types' has changed."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3189 (setq org-link-types-re
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3190 (concat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3191 "\\`\\(" (mapconcat 'identity org-link-types "\\|") "\\):")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3192 org-link-re-with-space
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3193 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3194 "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3195 "\\([^" org-non-link-chars " ]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3196 "[^" org-non-link-chars "]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3197 "[^" org-non-link-chars " ]\\)>?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3198 org-link-re-with-space2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3199 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3200 "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3201 "\\([^" org-non-link-chars " ]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3202 "[^]\t\n\r]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3203 "[^" org-non-link-chars " ]\\)>?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3204 org-angle-link-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3205 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3206 "<\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3207 "\\([^" org-non-link-chars " ]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3208 "[^" org-non-link-chars "]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3209 "\\)>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3210 org-plain-link-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3211 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3212 "\\<\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3213 "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3214 org-bracket-link-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3215 "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3216 org-bracket-link-analytic-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3217 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3218 "\\[\\["
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3219 "\\(\\(" (mapconcat 'identity org-link-types "\\|") "\\):\\)?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3220 "\\([^]]+\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3221 "\\]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3222 "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3223 "\\]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3224 org-any-link-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3225 (concat "\\(" org-bracket-link-regexp "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3226 org-angle-link-re "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3227 org-plain-link-re "\\)")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3228
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3229 (org-make-link-regexps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3230
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3231 (defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^\r\n>]*?\\)>"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3232 "Regular expression for fast time stamp matching.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3233 (defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^\r\n>]*?\\)[]>]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3234 "Regular expression for fast time stamp matching.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3235 (defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]-+0-9>\r\n ]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3236 "Regular expression matching time strings for analysis.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3237 This one does not require the space after the date, so it can be used
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3238 on a string that terminates immediately after the date.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3239 (defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) +\\([^]-+0-9>\r\n ]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3240 "Regular expression matching time strings for analysis.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3241 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 "[^>\n]\\{0,16\\}>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3242 "Regular expression matching time stamps, with groups.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3243 (defconst org-ts-regexp3 (concat "[[<]" org-ts-regexp1 "[^]>\n]\\{0,16\\}[]>]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3244 "Regular expression matching time stamps (also [..]), with groups.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3245 (defconst org-tr-regexp (concat org-ts-regexp "--?-?" org-ts-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3246 "Regular expression matching a time stamp range.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3247 (defconst org-tr-regexp-both
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3248 (concat org-ts-regexp-both "--?-?" org-ts-regexp-both)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3249 "Regular expression matching a time stamp range.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3250 (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3251 org-ts-regexp "\\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3252 "Regular expression matching a time stamp or time stamp range.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3253 (defconst org-tsr-regexp-both (concat org-ts-regexp-both "\\(--?-?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3254 org-ts-regexp-both "\\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3255 "Regular expression matching a time stamp or time stamp range.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3256 The time stamps may be either active or inactive.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3257
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3258 (defvar org-emph-face nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3259
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3260 (defun org-do-emphasis-faces (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3261 "Run through the buffer and add overlays to links."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3262 (let (rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3263 (while (and (not rtn) (re-search-forward org-emph-re limit t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3264 (if (not (= (char-after (match-beginning 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3265 (char-after (match-beginning 4))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3266 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3267 (setq rtn t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3268 (font-lock-prepend-text-property (match-beginning 2) (match-end 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3269 'face
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3270 (nth 1 (assoc (match-string 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3271 org-emphasis-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3272 (add-text-properties (match-beginning 2) (match-end 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3273 '(font-lock-multiline t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3274 (when org-hide-emphasis-markers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3275 (add-text-properties (match-end 4) (match-beginning 5)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3276 '(invisible org-link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3277 (add-text-properties (match-beginning 3) (match-end 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3278 '(invisible org-link)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3279 (backward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3280 rtn))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3281
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3282 (defun org-emphasize (&optional char)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3283 "Insert or change an emphasis, i.e. a font like bold or italic.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3284 If there is an active region, change that region to a new emphasis.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3285 If there is no region, just insert the marker characters and position
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3286 the cursor between them.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3287 CHAR should be either the marker character, or the first character of the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3288 HTML tag associated with that emphasis. If CHAR is a space, the means
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3289 to remove the emphasis of the selected region.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3290 If char is not given (for example in an interactive call) it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3291 will be prompted for."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3292 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3293 (let ((eal org-emphasis-alist) e det
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3294 (erc org-emphasis-regexp-components)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3295 (prompt "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3296 (string "") beg end move tag c s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3297 (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3298 (setq beg (region-beginning) end (region-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3299 string (buffer-substring beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3300 (setq move t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3301
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3302 (while (setq e (pop eal))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3303 (setq tag (car (org-split-string (nth 2 e) "[ <>/]+"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3304 c (aref tag 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3305 (push (cons c (string-to-char (car e))) det)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3306 (setq prompt (concat prompt (format " [%s%c]%s" (car e) c
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3307 (substring tag 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3308 (unless char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3309 (message "%s" (concat "Emphasis marker or tag:" prompt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3310 (setq char (read-char-exclusive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3311 (setq char (or (cdr (assoc char det)) char))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3312 (if (equal char ?\ )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3313 (setq s "" move nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3314 (unless (assoc (char-to-string char) org-emphasis-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3315 (error "No such emphasis marker: \"%c\"" char))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3316 (setq s (char-to-string char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3317 (while (and (> (length string) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3318 (equal (substring string 0 1) (substring string -1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3319 (assoc (substring string 0 1) org-emphasis-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3320 (setq string (substring string 1 -1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3321 (setq string (concat s string s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3322 (if beg (delete-region beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3323 (unless (or (bolp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3324 (string-match (concat "[" (nth 0 erc) "\n]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3325 (char-to-string (char-before (point)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3326 (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3327 (unless (string-match (concat "[" (nth 1 erc) "\n]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3328 (char-to-string (char-after (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3329 (insert " ") (backward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3330 (insert string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3331 (and move (backward-char 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3332
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3333 (defconst org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3334 '(mouse-face highlight keymap invisible intangible help-echo org-linked-text))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3335
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3336
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3337 (defun org-activate-plain-links (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3338 "Run through the buffer and add overlays to links."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3339 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3340 (let (f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3341 (while (re-search-forward org-plain-link-re limit t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3342 (setq f (get-text-property (match-beginning 0) 'face))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3343 (if (or (eq f 'org-tag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3344 (and (listp f) (memq 'org-tag f)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3345 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3346 (add-text-properties (match-beginning 0) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3347 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3348 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3349 'keymap org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3350 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3351 (throw 'exit t))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3352
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3353 (defun org-activate-code (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3354 (if (re-search-forward "^[ \t]*\\(:.*\\)" limit t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3355 (unless (get-text-property (match-beginning 1) 'face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3356 (remove-text-properties (match-beginning 0) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3357 '(display t invisible t intangible t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3358 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3359
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3360 (defun org-activate-angle-links (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3361 "Run through the buffer and add overlays to links."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3362 (if (re-search-forward org-angle-link-re limit t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3363 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3364 (add-text-properties (match-beginning 0) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3365 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3366 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3367 'keymap org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3368 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3369 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3370
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3371 (defun org-activate-bracket-links (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3372 "Run through the buffer and add overlays to bracketed links."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3373 (if (re-search-forward org-bracket-link-regexp limit t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3374 (let* ((help (concat "LINK: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3375 (org-match-string-no-properties 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3376 ;; FIXME: above we should remove the escapes.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3377 ;; but that requires another match, protecting match data,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3378 ;; a lot of overhead for font-lock.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3379 (ip (org-maybe-intangible
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3380 (list 'invisible 'org-link 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3381 'keymap org-mouse-map 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3382 'font-lock-multiline t 'help-echo help)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3383 (vp (list 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3384 'keymap org-mouse-map 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3385 ' font-lock-multiline t 'help-echo help)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3386 ;; We need to remove the invisible property here. Table narrowing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3387 ;; may have made some of this invisible.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3388 (remove-text-properties (match-beginning 0) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3389 '(invisible nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3390 (if (match-end 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3391 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3392 (add-text-properties (match-beginning 0) (match-beginning 3) ip)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3393 (add-text-properties (match-beginning 3) (match-end 3) vp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3394 (add-text-properties (match-end 3) (match-end 0) ip))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3395 (add-text-properties (match-beginning 0) (match-beginning 1) ip)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3396 (add-text-properties (match-beginning 1) (match-end 1) vp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3397 (add-text-properties (match-end 1) (match-end 0) ip))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3398 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3399
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3400 (defun org-activate-dates (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3401 "Run through the buffer and add overlays to dates."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3402 (if (re-search-forward org-tsr-regexp-both limit t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3403 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3404 (add-text-properties (match-beginning 0) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3405 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3406 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3407 'keymap org-mouse-map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3408 (when org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3409 (if (match-end 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3410 (org-display-custom-time (match-beginning 3) (match-end 3)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3411 (org-display-custom-time (match-beginning 1) (match-end 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3412 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3413
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3414 (defvar org-target-link-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3415 "Regular expression matching radio targets in plain text.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3416 (defvar org-target-regexp "<<\\([^<>\n\r]+\\)>>"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3417 "Regular expression matching a link target.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3418 (defvar org-radio-target-regexp "<<<\\([^<>\n\r]+\\)>>>"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3419 "Regular expression matching a radio target.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3420 (defvar org-any-target-regexp "<<<?\\([^<>\n\r]+\\)>>>?" ; FIXME, not exact, would match <<<aaa>> as a radio target.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3421 "Regular expression matching any target.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3422
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3423 (defun org-activate-target-links (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3424 "Run through the buffer and add overlays to target matches."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3425 (when org-target-link-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3426 (let ((case-fold-search t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3427 (if (re-search-forward org-target-link-regexp limit t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3428 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3429 (add-text-properties (match-beginning 0) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3430 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3431 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3432 'keymap org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3433 'help-echo "Radio target link"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3434 'org-linked-text t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3435 t)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3436
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3437 (defun org-update-radio-target-regexp ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3438 "Find all radio targets in this file and update the regular expression."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3439 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3440 (when (memq 'radio org-activate-links)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3441 (setq org-target-link-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3442 (org-make-target-link-regexp (org-all-targets 'radio)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3443 (org-restart-font-lock)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3444
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3445 (defun org-hide-wide-columns (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3446 (let (s e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3447 (setq s (text-property-any (point) (or limit (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3448 'org-cwidth t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3449 (when s
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3450 (setq e (next-single-property-change s 'org-cwidth))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3451 (add-text-properties s e (org-maybe-intangible '(invisible org-cwidth)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3452 (goto-char e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3453 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3454
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3455 (defvar org-latex-and-specials-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3456 "Regular expression for highlighting export special stuff.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3457 (defvar org-match-substring-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3458 (defvar org-match-substring-with-braces-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3459 (defvar org-export-html-special-string-regexps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3460
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3461 (defun org-compute-latex-and-specials-regexp ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3462 "Compute regular expression for stuff treated specially by exporters."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3463 (if (not org-highlight-latex-fragments-and-specials)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3464 (org-set-local 'org-latex-and-specials-regexp nil)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3465 (require 'org-exp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3466 (let*
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3467 ((matchers (plist-get org-format-latex-options :matchers))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3468 (latexs (delq nil (mapcar (lambda (x) (if (member (car x) matchers) x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3469 org-latex-regexps)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3470 (options (org-combine-plists (org-default-export-plist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3471 (org-infile-export-plist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3472 (org-export-with-sub-superscripts (plist-get options :sub-superscript))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3473 (org-export-with-LaTeX-fragments (plist-get options :LaTeX-fragments))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3474 (org-export-with-TeX-macros (plist-get options :TeX-macros))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3475 (org-export-html-expand (plist-get options :expand-quoted-html))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3476 (org-export-with-special-strings (plist-get options :special-strings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3477 (re-sub
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3478 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3479 ((equal org-export-with-sub-superscripts '{})
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3480 (list org-match-substring-with-braces-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3481 (org-export-with-sub-superscripts
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3482 (list org-match-substring-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3483 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3484 (re-latex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3485 (if org-export-with-LaTeX-fragments
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3486 (mapcar (lambda (x) (nth 1 x)) latexs)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3487 (re-macros
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3488 (if org-export-with-TeX-macros
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3489 (list (concat "\\\\"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3490 (regexp-opt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3491 (append (mapcar 'car org-html-entities)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3492 (if (boundp 'org-latex-entities)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3493 org-latex-entities nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3494 'words))) ; FIXME
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3495 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3496 ;; (list "\\\\\\(?:[a-zA-Z]+\\)")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3497 (re-special (if org-export-with-special-strings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3498 (mapcar (lambda (x) (car x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3499 org-export-html-special-string-regexps)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3500 (re-rest
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3501 (delq nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3502 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3503 (if org-export-html-expand "@<[^>\n]+>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3504 ))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3505 (org-set-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3506 'org-latex-and-specials-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3507 (mapconcat 'identity (append re-latex re-sub re-macros re-special
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3508 re-rest) "\\|")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3509
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3510 (defun org-do-latex-and-special-faces (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3511 "Run through the buffer and add overlays to links."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3512 (when org-latex-and-specials-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3513 (let (rtn d)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3514 (while (and (not rtn) (re-search-forward org-latex-and-specials-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3515 limit t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3516 (if (not (memq (car-safe (get-text-property (1+ (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3517 'face))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3518 '(org-code org-verbatim underline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3519 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3520 (setq rtn t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3521 d (cond ((member (char-after (1+ (match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3522 '(?_ ?^)) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3523 (t 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3524 (font-lock-prepend-text-property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3525 (+ d (match-beginning 0)) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3526 'face 'org-latex-and-export-specials)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3527 (add-text-properties (+ d (match-beginning 0)) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3528 '(font-lock-multiline t)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3529 rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3530
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3531 (defun org-restart-font-lock ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3532 "Restart font-lock-mode, to force refontification."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3533 (when (and (boundp 'font-lock-mode) font-lock-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3534 (font-lock-mode -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3535 (font-lock-mode 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3536
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3537 (defun org-all-targets (&optional radio)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3538 "Return a list of all targets in this file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3539 With optional argument RADIO, only find radio targets."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3540 (let ((re (if radio org-radio-target-regexp org-target-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3541 rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3542 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3543 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3544 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3545 (add-to-list 'rtn (downcase (org-match-string-no-properties 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3546 rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3547
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3548 (defun org-make-target-link-regexp (targets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3549 "Make regular expression matching all strings in TARGETS.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3550 The regular expression finds the targets also if there is a line break
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3551 between words."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3552 (and targets
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3553 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3554 "\\<\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3555 (mapconcat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3556 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3557 (while (string-match " +" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3558 (setq x (replace-match "\\s-+" t t x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3559 x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3560 targets
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3561 "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3562 "\\)\\>")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3563
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3564 (defun org-activate-tags (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3565 (if (re-search-forward (org-re "^\\*+.*[ \t]\\(:[[:alnum:]_@:]+:\\)[ \r\n]") limit t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3566 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3567 (add-text-properties (match-beginning 1) (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3568 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3569 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3570 'keymap org-mouse-map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3571 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3572
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3573 (defun org-outline-level ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3574 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3575 (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3576 (if (match-beginning 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3577 (+ (org-get-string-indentation (match-string 1)) 1000)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3578 (1- (- (match-end 0) (match-beginning 0))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3579
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3580 (defvar org-font-lock-keywords nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3581
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3582 (defconst org-property-re (org-re "^[ \t]*\\(:\\([[:alnum:]_]+\\):\\)[ \t]*\\([^ \t\r\n].*\\)")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3583 "Regular expression matching a property line.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3584
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3585 (defun org-set-font-lock-defaults ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3586 (let* ((em org-fontify-emphasized-text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3587 (lk org-activate-links)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3588 (org-font-lock-extra-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3589 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3590 ;; Headlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3591 '("^\\(\\**\\)\\(\\* \\)\\(.*\\)" (1 (org-get-level-face 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3592 (2 (org-get-level-face 2)) (3 (org-get-level-face 3)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3593 ;; Table lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3594 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3595 (1 'org-table t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3596 ;; Table internals
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3597 '("^[ \t]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3598 '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3599 '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3600 ;; Drawers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3601 (list org-drawer-regexp '(0 'org-special-keyword t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3602 (list "^[ \t]*:END:" '(0 'org-special-keyword t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3603 ;; Properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3604 (list org-property-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3605 '(1 'org-special-keyword t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3606 '(3 'org-property-value t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3607 (if org-format-transports-properties-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3608 '("| *\\(<[0-9]+>\\) *" (1 'org-formula t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3609 ;; Links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3610 (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3611 (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3612 (if (memq 'plain lk) '(org-activate-plain-links (0 'org-link t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3613 (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3614 (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3615 (if (memq 'date lk) '(org-activate-dates (0 'org-date t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3616 '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3617 '(org-hide-wide-columns (0 nil append))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3618 ;; TODO lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3619 (list (concat "^\\*+[ \t]+" org-todo-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3620 '(1 (org-get-todo-face 1) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3621 ;; DONE
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3622 (if org-fontify-done-headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3623 (list (concat "^[*]+ +\\<\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3624 (mapconcat 'regexp-quote org-done-keywords "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3625 "\\)\\(.*\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3626 '(2 'org-headline-done t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3627 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3628 ;; Priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3629 (list (concat "\\[#[A-Z0-9]\\]") '(0 'org-special-keyword t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3630 ;; Special keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3631 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3632 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3633 (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3634 (list (concat "\\<" org-clock-string) '(0 'org-special-keyword t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3635 ;; Emphasis
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3636 (if em
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3637 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3638 '(org-do-emphasis-faces (0 nil append))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3639 '(org-do-emphasis-faces)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3640 ;; Checkboxes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3641 '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3642 2 'bold prepend)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3643 (if org-provide-checkbox-statistics
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3644 '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3645 (0 (org-get-checkbox-statistics-face) t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3646 (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3647 '(1 'org-archived prepend))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3648 ;; Specials
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3649 '(org-do-latex-and-special-faces)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3650 ;; Code
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3651 '(org-activate-code (1 'org-code t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3652 ;; COMMENT
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3653 (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3654 "\\|" org-quote-string "\\)\\>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3655 '(1 'org-special-keyword t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3656 '("^#.*" (0 'font-lock-comment-face t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3657 )))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3658 (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3659 ;; Now set the full font-lock-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3660 (org-set-local 'org-font-lock-keywords org-font-lock-extra-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3661 (org-set-local 'font-lock-defaults
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3662 '(org-font-lock-keywords t nil nil backward-paragraph))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3663 (kill-local-variable 'font-lock-keywords) nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3664
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3665 (defvar org-m nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3666 (defvar org-l nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3667 (defvar org-f nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3668 (defun org-get-level-face (n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3669 "Get the right face for match N in font-lock matching of healdines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3670 (setq org-l (- (match-end 2) (match-beginning 1) 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3671 (if org-odd-levels-only (setq org-l (1+ (/ org-l 2))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3672 (setq org-f (nth (% (1- org-l) org-n-level-faces) org-level-faces))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3673 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3674 ((eq n 1) (if org-hide-leading-stars 'org-hide org-f))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3675 ((eq n 2) org-f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3676 (t (if org-level-color-stars-only nil org-f))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3677
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3678 (defun org-get-todo-face (kwd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3679 "Get the right face for a TODO keyword KWD.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3680 If KWD is a number, get the corresponding match group."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3681 (if (numberp kwd) (setq kwd (match-string kwd)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3682 (or (cdr (assoc kwd org-todo-keyword-faces))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3683 (and (member kwd org-done-keywords) 'org-done)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3684 'org-todo))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3685
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3686 (defun org-unfontify-region (beg end &optional maybe_loudly)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3687 "Remove fontification and activation overlays from links."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3688 (font-lock-default-unfontify-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3689 (let* ((buffer-undo-list t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3690 (inhibit-read-only t) (inhibit-point-motion-hooks t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3691 (inhibit-modification-hooks t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3692 deactivate-mark buffer-file-name buffer-file-truename)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3693 (remove-text-properties beg end
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3694 '(mouse-face t keymap t org-linked-text t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3695 invisible t intangible t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3696
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3697 ;;;; Visibility cycling, including org-goto and indirect buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3698
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3699 ;;; Cycling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3700
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3701 (defvar org-cycle-global-status nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3702 (make-variable-buffer-local 'org-cycle-global-status)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3703 (defvar org-cycle-subtree-status nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3704 (make-variable-buffer-local 'org-cycle-subtree-status)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3705
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3706 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3707 (defun org-cycle (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3708 "Visibility cycling for Org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3709
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3710 - When this function is called with a prefix argument, rotate the entire
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3711 buffer through 3 states (global cycling)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3712 1. OVERVIEW: Show only top-level headlines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3713 2. CONTENTS: Show all headlines of all levels, but no body text.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3714 3. SHOW ALL: Show everything.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3715
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3716 - When point is at the beginning of a headline, rotate the subtree started
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3717 by this line through 3 different states (local cycling)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3718 1. FOLDED: Only the main headline is shown.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3719 2. CHILDREN: The main headline and the direct children are shown.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3720 From this state, you can move to one of the children
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3721 and zoom in further.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3722 3. SUBTREE: Show the entire subtree, including body text.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3723
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3724 - When there is a numeric prefix, go up to a heading with level ARG, do
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3725 a `show-subtree' and return to the previous cursor position. If ARG
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3726 is negative, go up that many levels.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3727
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3728 - When point is not at the beginning of a headline, execute
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3729 `indent-relative', like TAB normally does. See the option
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3730 `org-cycle-emulate-tab' for details.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3731
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3732 - Special case: if point is at the beginning of the buffer and there is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3733 no headline in line 1, this function will act as if called with prefix arg.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3734 But only if also the variable `org-cycle-global-at-bob' is t."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3735 (interactive "P")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3736 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3737 (let* ((outline-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3738 (if (and (org-mode-p) org-cycle-include-plain-lists)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3739 "\\(?:\\*+ \\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) \\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3740 outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3741 (bob-special (and org-cycle-global-at-bob (bobp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3742 (not (looking-at outline-regexp))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3743 (org-cycle-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3744 (if bob-special
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3745 (delq 'org-optimize-window-after-visibility-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3746 (copy-sequence org-cycle-hook))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3747 org-cycle-hook))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3748 (pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3749
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3750 (if (or bob-special (equal arg '(4)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3751 ;; special case: use global cycling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3752 (setq arg t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3753
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3754 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3755
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3756 ((org-at-table-p 'any)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3757 ;; Enter the table or move to the next field in the table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3758 (or (org-table-recognize-table.el)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3759 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3760 (if arg (org-table-edit-field t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3761 (org-table-justify-field-maybe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3762 (call-interactively 'org-table-next-field)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3763
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3764 ((eq arg t) ;; Global cycling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3765
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3766 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3767 ((and (eq last-command this-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3768 (eq org-cycle-global-status 'overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3769 ;; We just created the overview - now do table of contents
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3770 ;; This can be slow in very large buffers, so indicate action
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3771 (message "CONTENTS...")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3772 (org-content)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3773 (message "CONTENTS...done")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3774 (setq org-cycle-global-status 'contents)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3775 (run-hook-with-args 'org-cycle-hook 'contents))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3776
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3777 ((and (eq last-command this-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3778 (eq org-cycle-global-status 'contents))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3779 ;; We just showed the table of contents - now show everything
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3780 (show-all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3781 (message "SHOW ALL")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3782 (setq org-cycle-global-status 'all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3783 (run-hook-with-args 'org-cycle-hook 'all))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3784
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3785 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3786 ;; Default action: go to overview
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3787 (org-overview)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3788 (message "OVERVIEW")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3789 (setq org-cycle-global-status 'overview)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3790 (run-hook-with-args 'org-cycle-hook 'overview))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3791
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3792 ((and org-drawers org-drawer-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3793 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3794 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3795 (looking-at org-drawer-regexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3796 ;; Toggle block visibility
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3797 (org-flag-drawer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3798 (not (get-char-property (match-end 0) 'invisible))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3799
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3800 ((integerp arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3801 ;; Show-subtree, ARG levels up from here.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3802 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3803 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3804 (outline-up-heading (if (< arg 0) (- arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3805 (- (funcall outline-level) arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3806 (org-show-subtree)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3807
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3808 ((and (save-excursion (beginning-of-line 1) (looking-at outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3809 (or (bolp) (not (eq org-cycle-emulate-tab 'exc-hl-bol))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3810 ;; At a heading: rotate between three different views
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3811 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3812 (let ((goal-column 0) eoh eol eos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3813 ;; First, some boundaries
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3814 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3815 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3816 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3817 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3818 (while (and (not (eobp)) ;; this is like `next-line'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3819 (get-char-property (1- (point)) 'invisible))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3820 (beginning-of-line 2)) (setq eol (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3821 (outline-end-of-heading) (setq eoh (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3822 (org-end-of-subtree t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3823 (unless (eobp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3824 (skip-chars-forward " \t\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3825 (beginning-of-line 1) ; in case this is an item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3826 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3827 (setq eos (1- (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3828 ;; Find out what to do next and set `this-command'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3829 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3830 ((= eos eoh)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3831 ;; Nothing is hidden behind this heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3832 (message "EMPTY ENTRY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3833 (setq org-cycle-subtree-status nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3834 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3835 (goto-char eos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3836 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3837 (if (org-invisible-p) (org-flag-heading nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3838 ((or (>= eol eos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3839 (not (string-match "\\S-" (buffer-substring eol eos))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3840 ;; Entire subtree is hidden in one line: open it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3841 (org-show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3842 (show-children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3843 (message "CHILDREN")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3844 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3845 (goto-char eos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3846 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3847 (if (org-invisible-p) (org-flag-heading nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3848 (setq org-cycle-subtree-status 'children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3849 (run-hook-with-args 'org-cycle-hook 'children))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3850 ((and (eq last-command this-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3851 (eq org-cycle-subtree-status 'children))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3852 ;; We just showed the children, now show everything.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3853 (org-show-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3854 (message "SUBTREE")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3855 (setq org-cycle-subtree-status 'subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3856 (run-hook-with-args 'org-cycle-hook 'subtree))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3857 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3858 ;; Default action: hide the subtree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3859 (hide-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3860 (message "FOLDED")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3861 (setq org-cycle-subtree-status 'folded)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3862 (run-hook-with-args 'org-cycle-hook 'folded)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3863
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3864 ;; TAB emulation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3865 (buffer-read-only (org-back-to-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3866
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3867 ((org-try-cdlatex-tab))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3868
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3869 ((and (eq org-cycle-emulate-tab 'exc-hl-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3870 (or (not (bolp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3871 (not (looking-at outline-regexp))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3872 (call-interactively (global-key-binding "\t")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3873
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3874 ((if (and (memq org-cycle-emulate-tab '(white whitestart))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3875 (save-excursion (beginning-of-line 1) (looking-at "[ \t]*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3876 (or (and (eq org-cycle-emulate-tab 'white)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3877 (= (match-end 0) (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3878 (and (eq org-cycle-emulate-tab 'whitestart)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3879 (>= (match-end 0) pos))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3880 t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3881 (eq org-cycle-emulate-tab t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3882 (call-interactively (global-key-binding "\t")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3883
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3884 (t (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3885 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3886 (org-cycle))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3887
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3888 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3889 (defun org-global-cycle (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3890 "Cycle the global visibility. For details see `org-cycle'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3891 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3892 (let ((org-cycle-include-plain-lists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3893 (if (org-mode-p) org-cycle-include-plain-lists nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3894 (if (integerp arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3895 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3896 (show-all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3897 (hide-sublevels arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3898 (setq org-cycle-global-status 'contents))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3899 (org-cycle '(4)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3900
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3901 (defun org-overview ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3902 "Switch to overview mode, shoing only top-level headlines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3903 Really, this shows all headlines with level equal or greater than the level
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3904 of the first headline in the buffer. This is important, because if the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3905 first headline is not level one, then (hide-sublevels 1) gives confusing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3906 results."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3907 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3908 (let ((level (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3909 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3910 (if (re-search-forward (concat "^" outline-regexp) nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3911 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3912 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3913 (funcall outline-level))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3914 (and level (hide-sublevels level))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3915
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3916 (defun org-content (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3917 "Show all headlines in the buffer, like a table of contents.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3918 With numerical argument N, show content up to level N."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3919 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3920 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3921 ;; Visit all headings and show their offspring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3922 (and (integerp arg) (org-overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3923 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3924 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3925 (while (and (progn (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3926 (outline-previous-visible-heading 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3927 (error (goto-char (point-min))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3928 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3929 (looking-at outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3930 (if (integerp arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3931 (show-children (1- arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3932 (show-branches))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3933 (if (bobp) (throw 'exit nil))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3934
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3935
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3936 (defun org-optimize-window-after-visibility-change (state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3937 "Adjust the window after a change in outline visibility.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3938 This function is the default value of the hook `org-cycle-hook'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3939 (when (get-buffer-window (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3940 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3941 ; ((eq state 'overview) (org-first-headline-recenter 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3942 ; ((eq state 'overview) (org-beginning-of-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3943 ((eq state 'content) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3944 ((eq state 'all) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3945 ((eq state 'folded) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3946 ((eq state 'children) (or (org-subtree-end-visible-p) (recenter 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3947 ((eq state 'subtree) (or (org-subtree-end-visible-p) (recenter 1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3948
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3949 (defun org-compact-display-after-subtree-move ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3950 (let (beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3951 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3952 (if (org-up-heading-safe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3953 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3954 (hide-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3955 (show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3956 (show-children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3957 (org-cycle-show-empty-lines 'children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3958 (org-cycle-hide-drawers 'children))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3959 (org-overview)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3960
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3961 (defun org-cycle-show-empty-lines (state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3962 "Show empty lines above all visible headlines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3963 The region to be covered depends on STATE when called through
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3964 `org-cycle-hook'. Lisp program can use t for STATE to get the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3965 entire buffer covered. Note that an empty line is only shown if there
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3966 are at least `org-cycle-separator-lines' empty lines before the headeline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3967 (when (> org-cycle-separator-lines 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3968 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3969 (let* ((n org-cycle-separator-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3970 (re (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3971 ((= n 1) "\\(\n[ \t]*\n\\*+\\) ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3972 ((= n 2) "^[ \t]*\\(\n[ \t]*\n\\*+\\) ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3973 (t (let ((ns (number-to-string (- n 2))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3974 (concat "^\\(?:[ \t]*\n\\)\\{" ns "," ns "\\}"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3975 "[ \t]*\\(\n[ \t]*\n\\*+\\) ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3976 beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3977 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3978 ((memq state '(overview contents t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3979 (setq beg (point-min) end (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3980 ((memq state '(children folded))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3981 (setq beg (point) end (progn (org-end-of-subtree t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3982 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3983 (point)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3984 (when beg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3985 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3986 (while (re-search-forward re end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3987 (if (not (get-char-property (match-end 1) 'invisible))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3988 (outline-flag-region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3989 (match-beginning 1) (match-end 1) nil)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3990 ;; Never hide empty lines at the end of the file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3991 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3992 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3993 (outline-previous-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3994 (outline-end-of-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3995 (if (and (looking-at "[ \t\n]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3996 (= (match-end 0) (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3997 (outline-flag-region (point) (match-end 0) nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3998
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3999 (defun org-cycle-hide-drawers (state)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4000 "Re-hide all drawers after a visibility state change."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4001 (when (and (org-mode-p)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4002 (not (memq state '(overview folded))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4003 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4004 (let* ((globalp (memq state '(contents all)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4005 (beg (if globalp (point-min) (point)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4006 (end (if globalp (point-max) (org-end-of-subtree t))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4007 (goto-char beg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4008 (while (re-search-forward org-drawer-regexp end t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4009 (org-flag-drawer t))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4010
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4011 (defun org-flag-drawer (flag)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4012 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4013 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4014 (when (looking-at "^[ \t]*:[a-zA-Z][a-zA-Z0-9]*:")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4015 (let ((b (match-end 0))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4016 (outline-regexp org-outline-regexp))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4017 (if (re-search-forward
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4018 "^[ \t]*:END:"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4019 (save-excursion (outline-next-heading) (point)) t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4020 (outline-flag-region b (point-at-eol) flag)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4021 (error ":END: line missing"))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4022
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4023
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4024
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4025 (defun org-subtree-end-visible-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4026 "Is the end of the current subtree visible?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4027 (pos-visible-in-window-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4028 (save-excursion (org-end-of-subtree t) (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4029
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4030 (defun org-first-headline-recenter (&optional N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4031 "Move cursor to the first headline and recenter the headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4032 Optional argument N means, put the headline into the Nth line of the window."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4033 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4034 (when (re-search-forward (concat "^\\(" outline-regexp "\\)") nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4035 (beginning-of-line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4036 (recenter (prefix-numeric-value N))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4037
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4038 ;;; Org-goto
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4039
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4040 (defvar org-goto-window-configuration nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4041 (defvar org-goto-marker nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4042 (defvar org-goto-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4043 (let ((map (make-sparse-keymap)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4044 (let ((cmds '(isearch-forward isearch-backward kill-ring-save set-mark-command mouse-drag-region universal-argument org-occur)) cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4045 (while (setq cmd (pop cmds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4046 (substitute-key-definition cmd cmd map global-map)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4047 (suppress-keymap map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4048 (org-defkey map "\C-m" 'org-goto-ret)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4049 (org-defkey map [(return)] 'org-goto-ret)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4050 (org-defkey map [(left)] 'org-goto-left)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4051 (org-defkey map [(right)] 'org-goto-right)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4052 (org-defkey map [(control ?g)] 'org-goto-quit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4053 (org-defkey map "\C-i" 'org-cycle)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4054 (org-defkey map [(tab)] 'org-cycle)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4055 (org-defkey map [(down)] 'outline-next-visible-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4056 (org-defkey map [(up)] 'outline-previous-visible-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4057 (if org-goto-auto-isearch
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4058 (if (fboundp 'define-key-after)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4059 (define-key-after map [t] 'org-goto-local-auto-isearch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4060 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4061 (org-defkey map "q" 'org-goto-quit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4062 (org-defkey map "n" 'outline-next-visible-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4063 (org-defkey map "p" 'outline-previous-visible-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4064 (org-defkey map "f" 'outline-forward-same-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4065 (org-defkey map "b" 'outline-backward-same-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4066 (org-defkey map "u" 'outline-up-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4067 (org-defkey map "/" 'org-occur)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4068 (org-defkey map "\C-c\C-n" 'outline-next-visible-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4069 (org-defkey map "\C-c\C-p" 'outline-previous-visible-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4070 (org-defkey map "\C-c\C-f" 'outline-forward-same-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4071 (org-defkey map "\C-c\C-b" 'outline-backward-same-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4072 (org-defkey map "\C-c\C-u" 'outline-up-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4073 map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4074
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4075 (defconst org-goto-help
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4076 "Browse buffer copy, to find location or copy text. Just type for auto-isearch.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4077 RET=jump to location [Q]uit and return to previous location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4078 \[Up]/[Down]=next/prev headline TAB=cycle visibility [/] org-occur")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4079
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4080 (defvar org-goto-start-pos) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4081
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4082 (defun org-goto (&optional alternative-interface)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4083 "Look up a different location in the current file, keeping current visibility.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4084
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4085 When you want look-up or go to a different location in a document, the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4086 fastest way is often to fold the entire buffer and then dive into the tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4087 This method has the disadvantage, that the previous location will be folded,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4088 which may not be what you want.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4089
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4090 This command works around this by showing a copy of the current buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4091 in an indirect buffer, in overview mode. You can dive into the tree in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4092 that copy, use org-occur and incremental search to find a location.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4093 When pressing RET or `Q', the command returns to the original buffer in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4094 which the visibility is still unchanged. After RET is will also jump to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4095 the location selected in the indirect buffer and expose the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4096 the headline hierarchy above."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4097 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4098 (let* ((org-refile-targets '((nil . (:maxlevel . 10))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4099 (org-refile-use-outline-path t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4100 (interface
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4101 (if (not alternative-interface)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4102 org-goto-interface
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4103 (if (eq org-goto-interface 'outline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4104 'outline-path-completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4105 'outline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4106 (org-goto-start-pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4107 (selected-point
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4108 (if (eq interface 'outline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4109 (car (org-get-location (current-buffer) org-goto-help))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4110 (nth 3 (org-refile-get-location "Goto: ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4111 (if selected-point
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4112 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4113 (org-mark-ring-push org-goto-start-pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4114 (goto-char selected-point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4115 (if (or (org-invisible-p) (org-invisible-p2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4116 (org-show-context 'org-goto)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4117 (message "Quit"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4118
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4119 (defvar org-goto-selected-point nil) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4120 (defvar org-goto-exit-command nil) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4121 (defvar org-goto-local-auto-isearch-map) ; defined below
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4122
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4123 (defun org-get-location (buf help)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4124 "Let the user select a location in the Org-mode buffer BUF.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4125 This function uses a recursive edit. It returns the selected position
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4126 or nil."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4127 (let ((isearch-mode-map org-goto-local-auto-isearch-map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4128 (isearch-hide-immediately nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4129 (isearch-search-fun-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4130 (lambda () 'org-goto-local-search-forward-headings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4131 (org-goto-selected-point org-goto-exit-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4132 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4133 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4134 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4135 (and (get-buffer "*org-goto*") (kill-buffer "*org-goto*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4136 (switch-to-buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4137 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4138 (make-indirect-buffer (current-buffer) "*org-goto*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4139 (error (make-indirect-buffer (current-buffer) "*org-goto*"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4140 (with-output-to-temp-buffer "*Help*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4141 (princ help))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4142 (shrink-window-if-larger-than-buffer (get-buffer-window "*Help*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4143 (setq buffer-read-only nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4144 (let ((org-startup-truncated t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4145 (org-startup-folded nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4146 (org-startup-align-all-tables nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4147 (org-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4148 (org-overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4149 (setq buffer-read-only t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4150 (if (and (boundp 'org-goto-start-pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4151 (integer-or-marker-p org-goto-start-pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4152 (let ((org-show-hierarchy-above t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4153 (org-show-siblings t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4154 (org-show-following-heading t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4155 (goto-char org-goto-start-pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4156 (and (org-invisible-p) (org-show-context)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4157 (goto-char (point-min)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4158 (org-beginning-of-line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4159 (message "Select location and press RET")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4160 (use-local-map org-goto-map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4161 (recursive-edit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4162 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4163 (kill-buffer "*org-goto*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4164 (cons org-goto-selected-point org-goto-exit-command)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4165
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4166 (defvar org-goto-local-auto-isearch-map (make-sparse-keymap))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4167 (set-keymap-parent org-goto-local-auto-isearch-map isearch-mode-map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4168 (define-key org-goto-local-auto-isearch-map "\C-i" 'isearch-other-control-char)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4169 (define-key org-goto-local-auto-isearch-map "\C-m" 'isearch-other-control-char)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4170
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4171 (defun org-goto-local-search-forward-headings (string bound noerror)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4172 "Search and make sure that anu matches are in headlines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4173 (catch 'return
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4174 (while (search-forward string bound noerror)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4175 (when (let ((context (mapcar 'car (save-match-data (org-context)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4176 (and (member :headline context)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4177 (not (member :tags context))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4178 (throw 'return (point))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4179
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4180 (defun org-goto-local-auto-isearch ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4181 "Start isearch."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4182 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4183 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4184 (let ((keys (this-command-keys)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4185 (when (eq (lookup-key isearch-mode-map keys) 'isearch-printing-char)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4186 (isearch-mode t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4187 (isearch-process-search-char (string-to-char keys)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4188
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4189 (defun org-goto-ret (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4190 "Finish `org-goto' by going to the new location."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4191 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4192 (setq org-goto-selected-point (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4193 org-goto-exit-command 'return)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4194 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4195
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4196 (defun org-goto-left ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4197 "Finish `org-goto' by going to the new location."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4198 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4199 (if (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4200 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4201 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4202 (setq org-goto-selected-point (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4203 org-goto-exit-command 'left)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4204 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4205 (error "Not on a heading")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4206
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4207 (defun org-goto-right ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4208 "Finish `org-goto' by going to the new location."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4209 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4210 (if (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4211 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4212 (setq org-goto-selected-point (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4213 org-goto-exit-command 'right)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4214 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4215 (error "Not on a heading")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4216
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4217 (defun org-goto-quit ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4218 "Finish `org-goto' without cursor motion."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4219 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4220 (setq org-goto-selected-point nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4221 (setq org-goto-exit-command 'quit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4222 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4223
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4224 ;;; Indirect buffer display of subtrees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4225
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4226 (defvar org-indirect-dedicated-frame nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4227 "This is the frame being used for indirect tree display.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4228 (defvar org-last-indirect-buffer nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4229
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4230 (defun org-tree-to-indirect-buffer (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4231 "Create indirect buffer and narrow it to current subtree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4232 With numerical prefix ARG, go up to this level and then take that tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4233 If ARG is negative, go up that many levels.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4234 If `org-indirect-buffer-display' is not `new-frame', the command removes the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4235 indirect buffer previously made with this command, to avoid proliferation of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4236 indirect buffers. However, when you call the command with a `C-u' prefix, or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4237 when `org-indirect-buffer-display' is `new-frame', the last buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4238 is kept so that you can work with several indirect buffers at the same time.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4239 If `org-indirect-buffer-display' is `dedicated-frame', the C-u prefix also
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4240 requests that a new frame be made for the new buffer, so that the dedicated
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4241 frame is not changed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4242 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4243 (let ((cbuf (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4244 (cwin (selected-window))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4245 (pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4246 beg end level heading ibuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4247 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4248 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4249 (when (numberp arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4250 (setq level (org-outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4251 (if (< arg 0) (setq arg (+ level arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4252 (while (> (setq level (org-outline-level)) arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4253 (outline-up-heading 1 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4254 (setq beg (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4255 heading (org-get-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4256 (org-end-of-subtree t) (setq end (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4257 (if (and (buffer-live-p org-last-indirect-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4258 (not (eq org-indirect-buffer-display 'new-frame))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4259 (not arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4260 (kill-buffer org-last-indirect-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4261 (setq ibuf (org-get-indirect-buffer cbuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4262 org-last-indirect-buffer ibuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4263 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4264 ((or (eq org-indirect-buffer-display 'new-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4265 (and arg (eq org-indirect-buffer-display 'dedicated-frame)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4266 (select-frame (make-frame))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4267 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4268 (switch-to-buffer ibuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4269 (org-set-frame-title heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4270 ((eq org-indirect-buffer-display 'dedicated-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4271 (raise-frame
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4272 (select-frame (or (and org-indirect-dedicated-frame
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4273 (frame-live-p org-indirect-dedicated-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4274 org-indirect-dedicated-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4275 (setq org-indirect-dedicated-frame (make-frame)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4276 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4277 (switch-to-buffer ibuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4278 (org-set-frame-title (concat "Indirect: " heading)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4279 ((eq org-indirect-buffer-display 'current-window)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4280 (switch-to-buffer ibuf))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4281 ((eq org-indirect-buffer-display 'other-window)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4282 (pop-to-buffer ibuf))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4283 (t (error "Invalid value.")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4284 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4285 (save-excursion (org-mode) (turn-on-font-lock)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4286 (narrow-to-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4287 (show-all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4288 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4289 (and (window-live-p cwin) (select-window cwin))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4290
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4291 (defun org-get-indirect-buffer (&optional buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4292 (setq buffer (or buffer (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4293 (let ((n 1) (base (buffer-name buffer)) bname)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4294 (while (buffer-live-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4295 (get-buffer (setq bname (concat base "-" (number-to-string n)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4296 (setq n (1+ n)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4297 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4298 (make-indirect-buffer buffer bname 'clone)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4299 (error (make-indirect-buffer buffer bname)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4300
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4301 (defun org-set-frame-title (title)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4302 "Set the title of the current frame to the string TITLE."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4303 ;; FIXME: how to name a single frame in XEmacs???
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4304 (unless (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4305 (modify-frame-parameters (selected-frame) (list (cons 'name title)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4306
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4307 ;;;; Structure editing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4308
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4309 ;;; Inserting headlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4310
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4311 (defun org-insert-heading (&optional force-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4312 "Insert a new heading or item with same depth at point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4313 If point is in a plain list and FORCE-HEADING is nil, create a new list item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4314 If point is at the beginning of a headline, insert a sibling before the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4315 current headline. If point is not at the beginning, do not split the line,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4316 but create the new hedline after the current line."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4317 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4318 (if (= (buffer-size) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4319 (insert "\n* ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4320 (when (or force-heading (not (org-insert-item)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4321 (let* ((head (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4322 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4323 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4324 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4325 (match-string 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4326 (error "*"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4327 (blank (cdr (assq 'heading org-blank-before-new-entry)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4328 pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4329 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4330 ((and (org-on-heading-p) (bolp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4331 (or (bobp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4332 (save-excursion (backward-char 1) (not (org-invisible-p)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4333 ;; insert before the current line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4334 (open-line (if blank 2 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4335 ((and (bolp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4336 (or (bobp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4337 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4338 (backward-char 1) (not (org-invisible-p)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4339 ;; insert right here
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4340 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4341 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4342 ;; in the middle of the line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4343 (org-show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4344 (let ((split
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4345 (org-get-alist-option org-M-RET-may-split-line 'headline))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4346 tags pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4347 (if (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4348 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4349 (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4350 (setq tags (and (match-end 2) (match-string 2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4351 (and (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4352 (delete-region (match-beginning 1) (match-end 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4353 (setq pos (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4354 (or split (end-of-line 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4355 (delete-horizontal-space)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4356 (newline (if blank 2 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4357 (when tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4358 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4359 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4360 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4361 (insert " " tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4362 (org-set-tags nil 'align))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4363 (or split (end-of-line 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4364 (newline (if blank 2 1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4365 (insert head) (just-one-space)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4366 (setq pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4367 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4368 (unless (= (point) pos) (just-one-space) (backward-delete-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4369 (run-hooks 'org-insert-heading-hook)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4370
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4371 (defun org-get-heading (&optional no-tags)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4372 "Return the heading of the current entry, without the stars."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4373 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4374 (org-back-to-heading t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4375 (if (looking-at
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4376 (if no-tags
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4377 (org-re "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@]+:[ \t]*\\)?$")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4378 "\\*+[ \t]+\\([^\r\n]*\\)"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4379 (match-string 1) "")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4380
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4381 (defun org-insert-heading-after-current ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4382 "Insert a new heading with same level as current, after current subtree."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4383 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4384 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4385 (org-insert-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4386 (org-move-subtree-down)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4387 (end-of-line 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4388
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4389 (defun org-insert-todo-heading (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4390 "Insert a new heading with the same level and TODO state as current heading.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4391 If the heading has no TODO state, or if the state is DONE, use the first
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4392 state (TODO by default). Also with prefix arg, force first state."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4393 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4394 (when (not (org-insert-item 'checkbox))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4395 (org-insert-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4396 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4397 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4398 (outline-previous-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4399 (looking-at org-todo-line-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4400 (if (or arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4401 (not (match-beginning 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4402 (member (match-string 2) org-done-keywords))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4403 (insert (car org-todo-keywords-1) " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4404 (insert (match-string 2) " "))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4405
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4406 (defun org-insert-subheading (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4407 "Insert a new subheading and demote it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4408 Works for outline headings and for plain lists alike."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4409 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4410 (org-insert-heading arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4411 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4412 ((org-on-heading-p) (org-do-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4413 ((org-at-item-p) (org-indent-item 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4414
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4415 (defun org-insert-todo-subheading (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4416 "Insert a new subheading with TODO keyword or checkbox and demote it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4417 Works for outline headings and for plain lists alike."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4418 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4419 (org-insert-todo-heading arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4420 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4421 ((org-on-heading-p) (org-do-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4422 ((org-at-item-p) (org-indent-item 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4423
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4424 ;;; Promotion and Demotion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4425
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4426 (defun org-promote-subtree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4427 "Promote the entire subtree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4428 See also `org-promote'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4429 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4430 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4431 (org-map-tree 'org-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4432 (org-fix-position-after-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4433
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4434 (defun org-demote-subtree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4435 "Demote the entire subtree. See `org-demote'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4436 See also `org-promote'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4437 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4438 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4439 (org-map-tree 'org-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4440 (org-fix-position-after-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4441
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4442
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4443 (defun org-do-promote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4444 "Promote the current heading higher up the tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4445 If the region is active in `transient-mark-mode', promote all headings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4446 in the region."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4447 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4448 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4449 (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4450 (org-map-region 'org-promote (region-beginning) (region-end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4451 (org-promote)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4452 (org-fix-position-after-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4453
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4454 (defun org-do-demote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4455 "Demote the current heading lower down the tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4456 If the region is active in `transient-mark-mode', demote all headings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4457 in the region."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4458 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4459 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4460 (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4461 (org-map-region 'org-demote (region-beginning) (region-end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4462 (org-demote)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4463 (org-fix-position-after-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4464
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4465 (defun org-fix-position-after-promote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4466 "Make sure that after pro/demotion cursor position is right."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4467 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4468 (when (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4469 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4470 (looking-at org-todo-line-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4471 (or (equal pos (match-end 1)) (equal pos (match-end 2))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4472 (cond ((eobp) (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4473 ((eolp) (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4474 ((equal (char-after) ?\ ) (forward-char 1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4475
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4476 (defun org-reduced-level (l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4477 (if org-odd-levels-only (1+ (floor (/ l 2))) l))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4478
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4479 (defun org-get-valid-level (level &optional change)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4480 "Rectify a level change under the influence of `org-odd-levels-only'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4481 LEVEL is a current level, CHANGE is by how much the level should be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4482 modified. Even if CHANGE is nil, LEVEL may be returned modified because
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4483 even level numbers will become the next higher odd number."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4484 (if org-odd-levels-only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4485 (cond ((or (not change) (= 0 change)) (1+ (* 2 (/ level 2))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4486 ((> change 0) (1+ (* 2 (/ (+ level (* 2 change)) 2))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4487 ((< change 0) (max 1 (1+ (* 2 (/ (+ level (* 2 change)) 2))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4488 (max 1 (+ level change))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4489
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4490 (if (boundp 'define-obsolete-function-alias)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4491 (if (or (featurep 'xemacs) (< emacs-major-version 23))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4492 (define-obsolete-function-alias 'org-get-legal-level
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4493 'org-get-valid-level)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4494 (define-obsolete-function-alias 'org-get-legal-level
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4495 'org-get-valid-level "23.1")))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4496
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4497 (defun org-promote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4498 "Promote the current heading higher up the tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4499 If the region is active in `transient-mark-mode', promote all headings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4500 in the region."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4501 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4502 (let* ((level (save-match-data (funcall outline-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4503 (up-head (concat (make-string (org-get-valid-level level -1) ?*) " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4504 (diff (abs (- level (length up-head) -1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4505 (if (= level 1) (error "Cannot promote to level 0. UNDO to recover if necessary"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4506 (replace-match up-head nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4507 ;; Fixup tag positioning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4508 (and org-auto-align-tags (org-set-tags nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4509 (if org-adapt-indentation (org-fixup-indentation (- diff)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4510
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4511 (defun org-demote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4512 "Demote the current heading lower down the tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4513 If the region is active in `transient-mark-mode', demote all headings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4514 in the region."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4515 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4516 (let* ((level (save-match-data (funcall outline-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4517 (down-head (concat (make-string (org-get-valid-level level 1) ?*) " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4518 (diff (abs (- level (length down-head) -1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4519 (replace-match down-head nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4520 ;; Fixup tag positioning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4521 (and org-auto-align-tags (org-set-tags nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4522 (if org-adapt-indentation (org-fixup-indentation diff))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4523
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4524 (defun org-map-tree (fun)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4525 "Call FUN for every heading underneath the current one."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4526 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4527 (let ((level (funcall outline-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4528 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4529 (funcall fun)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4530 (while (and (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4531 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4532 (> (funcall outline-level) level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4533 (not (eobp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4534 (funcall fun)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4535
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4536 (defun org-map-region (fun beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4537 "Call FUN for every heading between BEG and END."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4538 (let ((org-ignore-region t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4539 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4540 (setq end (copy-marker end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4541 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4542 (if (and (re-search-forward (concat "^" outline-regexp) nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4543 (< (point) end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4544 (funcall fun))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4545 (while (and (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4546 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4547 (< (point) end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4548 (not (eobp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4549 (funcall fun)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4550
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4551 (defun org-fixup-indentation (diff)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4552 "Change the indentation in the current entry by DIFF
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4553 However, if any line in the current entry has no indentation, or if it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4554 would end up with no indentation after the change, nothing at all is done."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4555 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4556 (let ((end (save-excursion (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4557 (point-marker)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4558 (prohibit (if (> diff 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4559 "^\\S-"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4560 (concat "^ \\{0," (int-to-string (- diff)) "\\}\\S-")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4561 col)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4562 (unless (save-excursion (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4563 (re-search-forward prohibit end t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4564 (while (and (< (point) end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4565 (re-search-forward "^[ \t]+" end t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4566 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4567 (setq col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4568 (if (< diff 0) (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4569 (indent-to (+ diff col))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4570 (move-marker end nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4571
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4572 (defun org-convert-to-odd-levels ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4573 "Convert an org-mode file with all levels allowed to one with odd levels.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4574 This will leave level 1 alone, convert level 2 to level 3, level 3 to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4575 level 5 etc."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4576 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4577 (when (yes-or-no-p "Are you sure you want to globally change levels to odd? ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4578 (let ((org-odd-levels-only nil) n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4579 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4580 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4581 (while (re-search-forward "^\\*\\*+ " nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4582 (setq n (- (length (match-string 0)) 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4583 (while (>= (setq n (1- n)) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4584 (org-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4585 (end-of-line 1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4586
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4587
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4588 (defun org-convert-to-oddeven-levels ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4589 "Convert an org-mode file with only odd levels to one with odd and even levels.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4590 This promotes level 3 to level 2, level 5 to level 3 etc. If the file contains a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4591 section with an even level, conversion would destroy the structure of the file. An error
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4592 is signaled in this case."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4593 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4594 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4595 ;; First check if there are no even levels
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4596 (when (re-search-forward "^\\(\\*\\*\\)+ " nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4597 (org-show-context t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4598 (error "Not all levels are odd in this file. Conversion not possible."))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4599 (when (yes-or-no-p "Are you sure you want to globally change levels to odd-even? ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4600 (let ((org-odd-levels-only nil) n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4601 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4602 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4603 (while (re-search-forward "^\\*\\*+ " nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4604 (setq n (/ (1- (length (match-string 0))) 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4605 (while (>= (setq n (1- n)) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4606 (org-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4607 (end-of-line 1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4608
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4609 (defun org-tr-level (n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4610 "Make N odd if required."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4611 (if org-odd-levels-only (1+ (/ n 2)) n))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4612
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4613 ;;; Vertical tree motion, cutting and pasting of subtrees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4614
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4615 (defun org-move-subtree-up (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4616 "Move the current subtree up past ARG headlines of the same level."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4617 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4618 (org-move-subtree-down (- (prefix-numeric-value arg))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4619
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4620 (defun org-move-subtree-down (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4621 "Move the current subtree down past ARG headlines of the same level."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4622 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4623 (setq arg (prefix-numeric-value arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4624 (let ((movfunc (if (> arg 0) 'outline-get-next-sibling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4625 'outline-get-last-sibling))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4626 (ins-point (make-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4627 (cnt (abs arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4628 beg beg0 end txt folded ne-beg ne-end ne-ins ins-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4629 ;; Select the tree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4630 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4631 (setq beg0 (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4632 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4633 (setq ne-beg (org-back-over-empty-lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4634 (setq beg (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4635 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4636 (save-excursion (outline-end-of-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4637 (setq folded (org-invisible-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4638 (outline-end-of-subtree))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4639 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4640 (setq ne-end (org-back-over-empty-lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4641 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4642 (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4643 (when (and (> arg 0) (org-first-sibling-p) (< ne-end ne-beg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4644 ;; include less whitespace
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4645 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4646 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4647 (forward-line (- ne-beg ne-end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4648 (setq beg (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4649 ;; Find insertion point, with error handling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4650 (while (> cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4651 (or (and (funcall movfunc) (looking-at outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4652 (progn (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4653 (error "Cannot move past superior level or buffer limit")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4654 (setq cnt (1- cnt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4655 (if (> arg 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4656 ;; Moving forward - still need to move over subtree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4657 (progn (org-end-of-subtree t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4658 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4659 (org-back-over-empty-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4660 (or (bolp) (newline)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4661 (setq ne-ins (org-back-over-empty-lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4662 (move-marker ins-point (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4663 (setq txt (buffer-substring beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4664 (delete-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4665 (outline-flag-region (1- beg) beg nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4666 (outline-flag-region (1- (point)) (point) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4667 (insert txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4668 (or (bolp) (insert "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4669 (setq ins-end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4670 (goto-char ins-point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4671 (org-skip-whitespace)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4672 (when (and (< arg 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4673 (org-first-sibling-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4674 (> ne-ins ne-beg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4675 ;; Move whitespace back to beginning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4676 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4677 (goto-char ins-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4678 (let ((kill-whole-line t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4679 (kill-line (- ne-ins ne-beg)) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4680 (insert (make-string (- ne-ins ne-beg) ?\n)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4681 (move-marker ins-point nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4682 (org-compact-display-after-subtree-move)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4683 (unless folded
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4684 (org-show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4685 (show-children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4686 (org-cycle-hide-drawers 'children))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4687
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4688 (defvar org-subtree-clip ""
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4689 "Clipboard for cut and paste of subtrees.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4690 This is actually only a copy of the kill, because we use the normal kill
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4691 ring. We need it to check if the kill was created by `org-copy-subtree'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4692
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4693 (defvar org-subtree-clip-folded nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4694 "Was the last copied subtree folded?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4695 This is used to fold the tree back after pasting.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4696
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4697 (defun org-cut-subtree (&optional n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4698 "Cut the current subtree into the clipboard.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4699 With prefix arg N, cut this many sequential subtrees.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4700 This is a short-hand for marking the subtree and then cutting it."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4701 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4702 (org-copy-subtree n 'cut))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4703
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4704 (defun org-copy-subtree (&optional n cut)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4705 "Cut the current subtree into the clipboard.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4706 With prefix arg N, cut this many sequential subtrees.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4707 This is a short-hand for marking the subtree and then copying it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4708 If CUT is non-nil, actually cut the subtree."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4709 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4710 (let (beg end folded (beg0 (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4711 (if (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4712 (org-back-to-heading nil) ; take what looks like a subtree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4713 (org-back-to-heading t)) ; take what is really there
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4714 (org-back-over-empty-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4715 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4716 (skip-chars-forward " \t\r\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4717 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4718 (save-excursion (outline-end-of-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4719 (setq folded (org-invisible-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4720 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4721 (outline-forward-same-level (1- n))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4722 (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4723 (org-end-of-subtree t t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4724 (org-back-over-empty-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4725 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4726 (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4727 (when (> end beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4728 (setq org-subtree-clip-folded folded)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4729 (if cut (kill-region beg end) (copy-region-as-kill beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4730 (setq org-subtree-clip (current-kill 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4731 (message "%s: Subtree(s) with %d characters"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4732 (if cut "Cut" "Copied")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4733 (length org-subtree-clip)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4734
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4735 (defun org-paste-subtree (&optional level tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4736 "Paste the clipboard as a subtree, with modification of headline level.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4737 The entire subtree is promoted or demoted in order to match a new headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4738 level. By default, the new level is derived from the visible headings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4739 before and after the insertion point, and taken to be the inferior headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4740 level of the two. So if the previous visible heading is level 3 and the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4741 next is level 4 (or vice versa), level 4 will be used for insertion.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4742 This makes sure that the subtree remains an independent subtree and does
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4743 not swallow low level entries.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4744
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4745 You can also force a different level, either by using a numeric prefix
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4746 argument, or by inserting the heading marker by hand. For example, if the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4747 cursor is after \"*****\", then the tree will be shifted to level 5.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4748
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4749 If you want to insert the tree as is, just use \\[yank].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4750
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4751 If optional TREE is given, use this text instead of the kill ring."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4752 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4753 (unless (org-kill-is-subtree-p tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4754 (error "%s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4755 (substitute-command-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4756 "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4757 (let* ((txt (or tree (and kill-ring (current-kill 0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4758 (^re (concat "^\\(" outline-regexp "\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4759 (re (concat "\\(" outline-regexp "\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4760 (^re_ (concat "\\(\\*+\\)[ \t]*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4761
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4762 (old-level (if (string-match ^re txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4763 (- (match-end 0) (match-beginning 0) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4764 -1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4765 (force-level (cond (level (prefix-numeric-value level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4766 ((string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4767 ^re_ (buffer-substring (point-at-bol) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4768 (- (match-end 1) (match-beginning 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4769 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4770 (previous-level (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4771 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4772 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4773 (outline-previous-visible-heading 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4774 (if (looking-at re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4775 (- (match-end 0) (match-beginning 0) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4776 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4777 (error 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4778 (next-level (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4779 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4780 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4781 (or (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4782 (outline-next-visible-heading 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4783 (if (looking-at re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4784 (- (match-end 0) (match-beginning 0) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4785 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4786 (error 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4787 (new-level (or force-level (max previous-level next-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4788 (shift (if (or (= old-level -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4789 (= new-level -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4790 (= old-level new-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4791 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4792 (- new-level old-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4793 (delta (if (> shift 0) -1 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4794 (func (if (> shift 0) 'org-demote 'org-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4795 (org-odd-levels-only nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4796 beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4797 ;; Remove the forced level indicator
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4798 (if force-level
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4799 (delete-region (point-at-bol) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4800 ;; Paste
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4801 (beginning-of-line 1)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4802 (org-back-over-empty-lines)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4803 (setq beg (point))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4804 (insert-before-markers txt)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4805 (unless (string-match "\n\\'" txt) (insert "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4806 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4807 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4808 (skip-chars-forward " \t\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4809 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4810 ;; Shift if necessary
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4811 (unless (= shift 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4812 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4813 (narrow-to-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4814 (while (not (= shift 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4815 (org-map-region func (point-min) (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4816 (setq shift (+ delta shift)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4817 (goto-char (point-min))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4818 (when (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4819 (message "Clipboard pasted as level %d subtree" new-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4820 (if (and kill-ring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4821 (eq org-subtree-clip (current-kill 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4822 org-subtree-clip-folded)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4823 ;; The tree was folded before it was killed/copied
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4824 (hide-subtree))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4825
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4826 (defun org-kill-is-subtree-p (&optional txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4827 "Check if the current kill is an outline subtree, or a set of trees.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4828 Returns nil if kill does not start with a headline, or if the first
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4829 headline level is not the largest headline level in the tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4830 So this will actually accept several entries of equal levels as well,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4831 which is OK for `org-paste-subtree'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4832 If optional TXT is given, check this string instead of the current kill."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4833 (let* ((kill (or txt (and kill-ring (current-kill 0)) ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4834 (start-level (and kill
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4835 (string-match (concat "\\`\\([ \t\n\r]*?\n\\)?\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4836 org-outline-regexp "\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4837 kill)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4838 (- (match-end 2) (match-beginning 2) 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4839 (re (concat "^" org-outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4840 (start (1+ (match-beginning 2))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4841 (if (not start-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4842 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4843 nil) ;; does not even start with a heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4844 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4845 (while (setq start (string-match re kill (1+ start)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4846 (when (< (- (match-end 0) (match-beginning 0) 1) start-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4847 (throw 'exit nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4848 t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4849
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4850 (defun org-narrow-to-subtree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4851 "Narrow buffer to the current subtree."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4852 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4853 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4854 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4855 (narrow-to-region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4856 (progn (org-back-to-heading) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4857 (progn (org-end-of-subtree t t) (point))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4858
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4859
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4860 ;;; Outline Sorting
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4861
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4862 (defun org-sort (with-case)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4863 "Call `org-sort-entries-or-items' or `org-table-sort-lines'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4864 Optional argument WITH-CASE means sort case-sensitively."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4865 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4866 (if (org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4867 (org-call-with-arg 'org-table-sort-lines with-case)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4868 (org-call-with-arg 'org-sort-entries-or-items with-case)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4869
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4870 (defun org-sort-remove-invisible (s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4871 (remove-text-properties 0 (length s) org-rm-props s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4872 (while (string-match org-bracket-link-regexp s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4873 (setq s (replace-match (if (match-end 2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4874 (match-string 3 s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4875 (match-string 1 s)) t t s)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4876 s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4877
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4878 (defvar org-priority-regexp) ; defined later in the file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4879
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4880 (defun org-sort-entries-or-items (&optional with-case sorting-type getkey-func property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4881 "Sort entries on a certain level of an outline tree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4882 If there is an active region, the entries in the region are sorted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4883 Else, if the cursor is before the first entry, sort the top-level items.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4884 Else, the children of the entry at point are sorted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4885
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4886 Sorting can be alphabetically, numerically, and by date/time as given by
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4887 the first time stamp in the entry. The command prompts for the sorting
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4888 type unless it has been given to the function through the SORTING-TYPE
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4889 argument, which needs to a character, any of (?n ?N ?a ?A ?t ?T ?p ?P ?f ?F).
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4890 If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies a function to be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4891 called with point at the beginning of the record. It must return either
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4892 a string or a number that should serve as the sorting key for that record.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4893
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4894 Comparing entries ignores case by default. However, with an optional argument
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4895 WITH-CASE, the sorting considers case as well."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4896 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4897 (let ((case-func (if with-case 'identity 'downcase))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4898 start beg end stars re re2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4899 txt what tmp plain-list-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4900 ;; Find beginning and end of region to sort
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4901 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4902 ((org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4903 ;; we will sort the region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4904 (setq end (region-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4905 what "region")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4906 (goto-char (region-beginning))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4907 (if (not (org-on-heading-p)) (outline-next-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4908 (setq start (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4909 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4910 ;; we will sort this plain list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4911 (org-beginning-of-item-list) (setq start (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4912 (org-end-of-item-list) (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4913 (goto-char start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4914 (setq plain-list-p t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4915 what "plain list"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4916 ((or (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4917 (condition-case nil (progn (org-back-to-heading) t) (error nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4918 ;; we will sort the children of the current headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4919 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4920 (setq start (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4921 end (progn (org-end-of-subtree t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4922 (org-back-over-empty-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4923 (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4924 what "children")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4925 (goto-char start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4926 (show-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4927 (outline-next-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4928 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4929 ;; we will sort the top-level entries in this file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4930 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4931 (or (org-on-heading-p) (outline-next-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4932 (setq start (point) end (point-max) what "top-level")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4933 (goto-char start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4934 (show-all)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4935
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4936 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4937 (if (>= beg end) (error "Nothing to sort"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4938
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4939 (unless plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4940 (looking-at "\\(\\*+\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4941 (setq stars (match-string 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4942 re (concat "^" (regexp-quote stars) " +")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4943 re2 (concat "^" (regexp-quote (substring stars 0 -1)) "[^*]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4944 txt (buffer-substring beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4945 (if (not (equal (substring txt -1) "\n")) (setq txt (concat txt "\n")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4946 (if (and (not (equal stars "*")) (string-match re2 txt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4947 (error "Region to sort contains a level above the first entry")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4948
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4949 (unless sorting-type
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4950 (message
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4951 (if plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4952 "Sort %s: [a]lpha [n]umeric [t]ime [f]unc A/N/T/F means reversed:"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4953 "Sort %s: [a]lpha [n]umeric [t]ime [p]riority p[r]operty todo[o]rder [f]unc A/N/T/P/O/F means reversed:")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4954 what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4955 (setq sorting-type (read-char-exclusive))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4956
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4957 (and (= (downcase sorting-type) ?f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4958 (setq getkey-func
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4959 (completing-read "Sort using function: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4960 obarray 'fboundp t nil nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4961 (setq getkey-func (intern getkey-func)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4962
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4963 (and (= (downcase sorting-type) ?r)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4964 (setq property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4965 (completing-read "Property: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4966 (mapcar 'list (org-buffer-property-keys t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4967 nil t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4968
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4969 (message "Sorting entries...")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4970
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4971 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4972 (narrow-to-region start end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4973
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4974 (let ((dcst (downcase sorting-type))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4975 (now (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4976 (sort-subr
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4977 (/= dcst sorting-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4978 ;; This function moves to the beginning character of the "record" to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4979 ;; be sorted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4980 (if plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4981 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4982 (if (org-at-item-p) t (goto-char (point-max))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4983 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4984 (if (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4985 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4986 (goto-char (point-max)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4987 ;; This function moves to the last character of the "record" being
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4988 ;; sorted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4989 (if plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4990 'org-end-of-item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4991 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4992 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4993 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4994 (outline-forward-same-level 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4995 (error
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4996 (goto-char (point-max)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4997
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4998 ;; This function returns the value that gets sorted against.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4999 (if plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5000 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5001 (when (looking-at "[ \t]*[-+*0-9.)]+[ \t]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5002 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5003 ((= dcst ?n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5004 (string-to-number (buffer-substring (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5005 (point-at-eol))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5006 ((= dcst ?a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5007 (buffer-substring (match-end 0) (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5008 ((= dcst ?t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5009 (if (re-search-forward org-ts-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5010 (point-at-eol) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5011 (org-time-string-to-time (match-string 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5012 now))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5013 ((= dcst ?f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5014 (if getkey-func
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5015 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5016 (setq tmp (funcall getkey-func))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5017 (if (stringp tmp) (setq tmp (funcall case-func tmp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5018 tmp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5019 (error "Invalid key function `%s'" getkey-func)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5020 (t (error "Invalid sorting type `%c'" sorting-type)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5021 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5022 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5023 ((= dcst ?n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5024 (if (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5025 (string-to-number (buffer-substring (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5026 (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5027 nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5028 ((= dcst ?a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5029 (funcall case-func (buffer-substring (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5030 (point-at-eol))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5031 ((= dcst ?t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5032 (if (re-search-forward org-ts-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5033 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5034 (forward-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5035 (point)) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5036 (org-time-string-to-time (match-string 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5037 now))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5038 ((= dcst ?p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5039 (if (re-search-forward org-priority-regexp (point-at-eol) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5040 (string-to-char (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5041 org-default-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5042 ((= dcst ?r)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5043 (or (org-entry-get nil property) ""))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5044 ((= dcst ?o)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5045 (if (looking-at org-complex-heading-regexp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5046 (- 9999 (length (member (match-string 2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5047 org-todo-keywords-1)))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5048 ((= dcst ?f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5049 (if getkey-func
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5050 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5051 (setq tmp (funcall getkey-func))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5052 (if (stringp tmp) (setq tmp (funcall case-func tmp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5053 tmp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5054 (error "Invalid key function `%s'" getkey-func)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5055 (t (error "Invalid sorting type `%c'" sorting-type)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5056 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5057 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5058 ((= dcst ?a) 'string<)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5059 ((= dcst ?t) 'time-less-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5060 (t nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5061 (message "Sorting entries...done")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5062
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5063 (defun org-do-sort (table what &optional with-case sorting-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5064 "Sort TABLE of WHAT according to SORTING-TYPE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5065 The user will be prompted for the SORTING-TYPE if the call to this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5066 function does not specify it. WHAT is only for the prompt, to indicate
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5067 what is being sorted. The sorting key will be extracted from
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5068 the car of the elements of the table.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5069 If WITH-CASE is non-nil, the sorting will be case-sensitive."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5070 (unless sorting-type
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5071 (message
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5072 "Sort %s: [a]lphabetic. [n]umeric. [t]ime. A/N/T means reversed:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5073 what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5074 (setq sorting-type (read-char-exclusive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5075 (let ((dcst (downcase sorting-type))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5076 extractfun comparefun)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5077 ;; Define the appropriate functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5078 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5079 ((= dcst ?n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5080 (setq extractfun 'string-to-number
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5081 comparefun (if (= dcst sorting-type) '< '>)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5082 ((= dcst ?a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5083 (setq extractfun (if with-case (lambda(x) (org-sort-remove-invisible x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5084 (lambda(x) (downcase (org-sort-remove-invisible x))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5085 comparefun (if (= dcst sorting-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5086 'string<
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5087 (lambda (a b) (and (not (string< a b))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5088 (not (string= a b)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5089 ((= dcst ?t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5090 (setq extractfun
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5091 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5092 (if (string-match org-ts-regexp x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5093 (time-to-seconds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5094 (org-time-string-to-time (match-string 0 x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5095 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5096 comparefun (if (= dcst sorting-type) '< '>)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5097 (t (error "Invalid sorting type `%c'" sorting-type)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5098
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5099 (sort (mapcar (lambda (x) (cons (funcall extractfun (car x)) (cdr x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5100 table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5101 (lambda (a b) (funcall comparefun (car a) (car b))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5102
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5103 ;;;; Plain list items, including checkboxes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5104
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5105 ;;; Plain list items
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5106
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5107 (defun org-at-item-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5108 "Is point in a line starting a hand-formatted item?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5109 (let ((llt org-plain-list-ordered-item-terminator))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5110 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5111 (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5112 (looking-at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5113 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5114 ((eq llt t) "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5115 ((= llt ?.) "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5116 ((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+))\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5117 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5118
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5119 (defun org-in-item-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5120 "It the cursor inside a plain list item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5121 Does not have to be the first line."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5122 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5123 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5124 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5125 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5126 (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5127 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5128 (error nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5129
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5130 (defun org-insert-item (&optional checkbox)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5131 "Insert a new item at the current level.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5132 Return t when things worked, nil when we are not in an item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5133 (when (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5134 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5135 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5136 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5137 (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5138 (if (org-invisible-p) (error "Invisible item"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5139 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5140 (error nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5141 (let* ((bul (match-string 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5142 (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5143 (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5144 (blank (cdr (assq 'plain-list-item org-blank-before-new-entry)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5145 pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5146 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5147 ((and (org-at-item-p) (<= (point) eow))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5148 ;; before the bullet
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5149 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5150 (open-line (if blank 2 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5151 ((<= (point) eow)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5152 (beginning-of-line 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5153 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5154 (unless (org-get-alist-option org-M-RET-may-split-line 'item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5155 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5156 (delete-horizontal-space))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5157 (newline (if blank 2 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5158 (insert bul (if checkbox "[ ]" ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5159 (just-one-space)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5160 (setq pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5161 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5162 (unless (= (point) pos) (just-one-space) (backward-delete-char 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5163 (org-maybe-renumber-ordered-list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5164 (and checkbox (org-update-checkbox-count-maybe))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5165 t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5166
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5167 ;;; Checkboxes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5168
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5169 (defun org-at-item-checkbox-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5170 "Is point at a line starting a plain-list item with a checklet?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5171 (and (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5172 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5173 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5174 (skip-chars-forward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5175 (looking-at "\\[[- X]\\]"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5176
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5177 (defun org-toggle-checkbox (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5178 "Toggle the checkbox in the current line."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5179 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5180 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5181 (let (beg end status (firstnew 'unknown))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5182 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5183 ((org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5184 (setq beg (region-beginning) end (region-end)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5185 ((org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5186 (setq beg (point) end (save-excursion (outline-next-heading) (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5187 ((org-at-item-checkbox-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5188 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5189 (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5190 (cond (arg "[-]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5191 ((member (match-string 0) '("[ ]" "[-]")) "[X]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5192 (t "[ ]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5193 t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5194 (goto-char pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5195 (throw 'exit t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5196 (t (error "Not at a checkbox or heading, and no active region")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5197 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5198 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5199 (while (< (point) end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5200 (when (org-at-item-checkbox-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5201 (setq status (equal (match-string 0) "[X]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5202 (when (eq firstnew 'unknown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5203 (setq firstnew (not status)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5204 (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5205 (if (if arg (not status) firstnew) "[X]" "[ ]") t t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5206 (beginning-of-line 2)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5207 (org-update-checkbox-count-maybe))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5208
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5209 (defun org-update-checkbox-count-maybe ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5210 "Update checkbox statistics unless turned off by user."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5211 (when org-provide-checkbox-statistics
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5212 (org-update-checkbox-count)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5213
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5214 (defun org-update-checkbox-count (&optional all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5215 "Update the checkbox statistics in the current section.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5216 This will find all statistic cookies like [57%] and [6/12] and update them
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5217 with the current numbers. With optional prefix argument ALL, do this for
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5218 the whole buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5219 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5220 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5221 (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5222 (beg (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5223 (progn (outline-back-to-heading) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5224 (error (point-min))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5225 (end (move-marker (make-marker)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5226 (progn (outline-next-heading) (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5227 (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5228 (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5229 (re-find (concat re "\\|" re-box))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5230 beg-cookie end-cookie is-percent c-on c-off lim
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5231 eline curr-ind next-ind continue-from startsearch
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5232 (cstat 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5233 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5234 (when all
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5235 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5236 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5237 (setq beg (point) end (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5238 (goto-char end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5239 ;; find each statistic cookie
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5240 (while (re-search-backward re-find beg t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5241 (setq beg-cookie (match-beginning 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5242 end-cookie (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5243 cstat (+ cstat (if end-cookie 1 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5244 startsearch (point-at-eol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5245 continue-from (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5246 is-percent (match-beginning 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5247 lim (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5248 ((org-on-heading-p) (outline-next-heading) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5249 ((org-at-item-p) (org-end-of-item) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5250 (t nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5251 c-on 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5252 c-off 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5253 (when lim
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5254 ;; find first checkbox for this cookie and gather
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5255 ;; statistics from all that are at this indentation level
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5256 (goto-char startsearch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5257 (if (re-search-forward re-box lim t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5258 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5259 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5260 (setq curr-ind (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5261 (setq next-ind curr-ind)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5262 (while (and (bolp) (org-at-item-p) (= curr-ind next-ind))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5263 (save-excursion (end-of-line) (setq eline (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5264 (if (re-search-forward re-box eline t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5265 (if (member (match-string 2) '("[ ]" "[-]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5266 (setq c-off (1+ c-off))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5267 (setq c-on (1+ c-on))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5268 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5269 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5270 (org-end-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5271 (setq next-ind (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5272 )))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5273 (goto-char continue-from)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5274 ;; update cookie
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5275 (when end-cookie
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5276 (delete-region beg-cookie end-cookie)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5277 (goto-char beg-cookie)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5278 (insert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5279 (if is-percent
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5280 (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5281 (format "[%d/%d]" c-on (+ c-on c-off)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5282 ;; update items checkbox if it has one
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5283 (when (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5284 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5285 (when (and (> (+ c-on c-off) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5286 (re-search-forward re-box (point-at-eol) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5287 (setq beg-cookie (match-beginning 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5288 end-cookie (match-end 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5289 (delete-region beg-cookie end-cookie)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5290 (goto-char beg-cookie)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5291 (cond ((= c-off 0) (insert "[X]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5292 ((= c-on 0) (insert "[ ]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5293 (t (insert "[-]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5294 )))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5295 (goto-char continue-from))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5296 (when (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5297 (message "Checkbox satistics updated %s (%d places)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5298 (if all "in entire file" "in current outline entry") cstat)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5299
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5300 (defun org-get-checkbox-statistics-face ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5301 "Select the face for checkbox statistics.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5302 The face will be `org-done' when all relevant boxes are checked. Otherwise
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5303 it will be `org-todo'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5304 (if (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5305 (if (equal (match-string 1) "100%") 'org-done 'org-todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5306 (if (and (> (match-end 2) (match-beginning 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5307 (equal (match-string 2) (match-string 3)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5308 'org-done
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5309 'org-todo)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5310
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5311 (defun org-get-indentation (&optional line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5312 "Get the indentation of the current line, interpreting tabs.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5313 When LINE is given, assume it represents a line and compute its indentation."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5314 (if line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5315 (if (string-match "^ *" (org-remove-tabs line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5316 (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5317 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5318 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5319 (skip-chars-forward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5320 (current-column))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5321
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5322 (defun org-remove-tabs (s &optional width)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5323 "Replace tabulators in S with spaces.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5324 Assumes that s is a single line, starting in column 0."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5325 (setq width (or width tab-width))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5326 (while (string-match "\t" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5327 (setq s (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5328 (make-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5329 (- (* width (/ (+ (match-beginning 0) width) width))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5330 (match-beginning 0)) ?\ )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5331 t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5332 s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5333
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5334 (defun org-fix-indentation (line ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5335 "Fix indentation in LINE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5336 IND is a cons cell with target and minimum indentation.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5337 If the current indenation in LINE is smaller than the minimum,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5338 leave it alone. If it is larger than ind, set it to the target."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5339 (let* ((l (org-remove-tabs line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5340 (i (org-get-indentation l))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5341 (i1 (car ind)) (i2 (cdr ind)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5342 (if (>= i i2) (setq l (substring line i2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5343 (if (> i1 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5344 (concat (make-string i1 ?\ ) l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5345 l)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5346
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5347 (defun org-beginning-of-item ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5348 "Go to the beginning of the current hand-formatted item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5349 If the cursor is not in an item, throw an error."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5350 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5351 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5352 (limit (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5353 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5354 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5355 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5356 (beginning-of-line 2) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5357 (error (point-min)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5358 (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5359 ind ind1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5360 (if (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5361 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5362 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5363 (skip-chars-forward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5364 (setq ind (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5365 (if (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5366 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5367 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5368 (if (or (bobp) (< (point) limit)) (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5369
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5370 (if (looking-at "[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5371 (setq ind1 ind-empty)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5372 (skip-chars-forward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5373 (setq ind1 (current-column)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5374 (if (< ind1 ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5375 (progn (beginning-of-line 1) (throw 'exit (org-at-item-p))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5376 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5377 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5378 (error "Not in an item")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5379
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5380 (defun org-end-of-item ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5381 "Go to the end of the current hand-formatted item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5382 If the cursor is not in an item, throw an error."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5383 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5384 (let* ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5385 ind1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5386 (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5387 (limit (save-excursion (outline-next-heading) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5388 (ind (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5389 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5390 (skip-chars-forward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5391 (current-column)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5392 (end (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5393 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5394 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5395 (if (eobp) (throw 'exit (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5396 (if (>= (point) limit) (throw 'exit (point-at-bol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5397 (if (looking-at "[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5398 (setq ind1 ind-empty)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5399 (skip-chars-forward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5400 (setq ind1 (current-column)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5401 (if (<= ind1 ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5402 (throw 'exit (point-at-bol)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5403 (if end
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5404 (goto-char end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5405 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5406 (error "Not in an item"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5407
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5408 (defun org-next-item ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5409 "Move to the beginning of the next item in the current plain list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5410 Error if not at a plain list, or if this is the last item in the list."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5411 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5412 (let (ind ind1 (pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5413 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5414 (setq ind (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5415 (org-end-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5416 (setq ind1 (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5417 (unless (and (org-at-item-p) (= ind ind1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5418 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5419 (error "On last item"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5420
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5421 (defun org-previous-item ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5422 "Move to the beginning of the previous item in the current plain list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5423 Error if not at a plain list, or if this is the first item in the list."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5424 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5425 (let (beg ind ind1 (pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5426 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5427 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5428 (setq ind (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5429 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5430 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5431 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5432 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5433 (if (looking-at "[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5434 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5435 (if (<= (setq ind1 (org-get-indentation)) ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5436 (throw 'exit t)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5437 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5438 (if (or (not (org-at-item-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5439 (< ind1 (1- ind)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5440 (error "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5441 (org-beginning-of-item))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5442 (error (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5443 (error "On first item")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5444
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5445 (defun org-first-list-item-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5446 "Is this heading the item in a plain list?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5447 (unless (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5448 (error "Not at a plain list item"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5449 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5450 (= (point) (save-excursion (org-beginning-of-item-list))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5451
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5452 (defun org-move-item-down ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5453 "Move the plain list item at point down, i.e. swap with following item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5454 Subitems (items with larger indentation) are considered part of the item,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5455 so this really moves item trees."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5456 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5457 (let (beg beg0 end end0 ind ind1 (pos (point)) txt ne-end ne-beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5458 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5459 (setq beg0 (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5460 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5461 (setq ne-beg (org-back-over-empty-lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5462 (setq beg (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5463 (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5464 (setq ind (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5465 (org-end-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5466 (setq end0 (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5467 (setq ind1 (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5468 (setq ne-end (org-back-over-empty-lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5469 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5470 (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5471 (when (and (org-first-list-item-p) (< ne-end ne-beg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5472 ;; include less whitespace
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5473 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5474 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5475 (forward-line (- ne-beg ne-end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5476 (setq beg (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5477 (goto-char end0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5478 (if (and (org-at-item-p) (= ind ind1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5479 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5480 (org-end-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5481 (org-back-over-empty-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5482 (setq txt (buffer-substring beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5483 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5484 (delete-region beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5485 (setq pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5486 (insert txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5487 (goto-char pos) (org-skip-whitespace)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5488 (org-maybe-renumber-ordered-list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5489 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5490 (error "Cannot move this item further down"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5491
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5492 (defun org-move-item-up (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5493 "Move the plain list item at point up, i.e. swap with previous item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5494 Subitems (items with larger indentation) are considered part of the item,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5495 so this really moves item trees."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5496 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5497 (let (beg beg0 end ind ind1 (pos (point)) txt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5498 ne-beg ne-ins ins-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5499 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5500 (setq beg0 (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5501 (setq ind (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5502 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5503 (setq ne-beg (org-back-over-empty-lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5504 (setq beg (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5505 (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5506 (org-end-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5507 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5508 (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5509 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5510 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5511 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5512 (if (looking-at "[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5513 (if org-empty-line-terminates-plain-lists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5514 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5515 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5516 (error "Cannot move this item further up"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5517 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5518 (if (<= (setq ind1 (org-get-indentation)) ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5519 (throw 'exit t)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5520 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5521 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5522 (error (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5523 (error "Cannot move this item further up")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5524 (setq ind1 (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5525 (if (and (org-at-item-p) (= ind ind1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5526 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5527 (setq ne-ins (org-back-over-empty-lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5528 (setq txt (buffer-substring beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5529 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5530 (delete-region beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5531 (setq pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5532 (insert txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5533 (setq ins-end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5534 (goto-char pos) (org-skip-whitespace)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5535
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5536 (when (and (org-first-list-item-p) (> ne-ins ne-beg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5537 ;; Move whitespace back to beginning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5538 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5539 (goto-char ins-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5540 (let ((kill-whole-line t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5541 (kill-line (- ne-ins ne-beg)) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5542 (insert (make-string (- ne-ins ne-beg) ?\n)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5543
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5544 (org-maybe-renumber-ordered-list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5545 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5546 (error "Cannot move this item further up"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5547
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5548 (defun org-maybe-renumber-ordered-list ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5549 "Renumber the ordered list at point if setup allows it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5550 This tests the user option `org-auto-renumber-ordered-lists' before
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5551 doing the renumbering."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5552 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5553 (when (and org-auto-renumber-ordered-lists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5554 (org-at-item-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5555 (if (match-beginning 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5556 (org-renumber-ordered-list 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5557 (org-fix-bullet-type))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5558
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5559 (defun org-maybe-renumber-ordered-list-safe ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5560 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5561 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5562 (org-maybe-renumber-ordered-list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5563 (error nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5564
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5565 (defun org-cycle-list-bullet (&optional which)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5566 "Cycle through the different itemize/enumerate bullets.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5567 This cycle the entire list level through the sequence:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5568
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5569 `-' -> `+' -> `*' -> `1.' -> `1)'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5570
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5571 If WHICH is a string, use that as the new bullet. If WHICH is an integer,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5572 0 meand `-', 1 means `+' etc."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5573 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5574 (org-preserve-lc
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5575 (org-beginning-of-item-list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5576 (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5577 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5578 (let ((current (match-string 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5579 (prevp (eq which 'previous))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5580 new)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5581 (setq new (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5582 ((and (numberp which)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5583 (nth (1- which) '("-" "+" "*" "1." "1)"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5584 ((string-match "-" current) (if prevp "1)" "+"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5585 ((string-match "\\+" current)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5586 (if prevp "-" (if (looking-at "\\S-") "1." "*")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5587 ((string-match "\\*" current) (if prevp "+" "1."))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5588 ((string-match "\\." current) (if prevp "*" "1)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5589 ((string-match ")" current) (if prevp "1." "-"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5590 (t (error "This should not happen"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5591 (and (looking-at "\\([ \t]*\\)\\S-+") (replace-match (concat "\\1" new)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5592 (org-fix-bullet-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5593 (org-maybe-renumber-ordered-list))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5594
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5595 (defun org-get-string-indentation (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5596 "What indentation has S due to SPACE and TAB at the beginning of the string?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5597 (let ((n -1) (i 0) (w tab-width) c)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5598 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5599 (while (< (setq n (1+ n)) (length s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5600 (setq c (aref s n))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5601 (cond ((= c ?\ ) (setq i (1+ i)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5602 ((= c ?\t) (setq i (* (/ (+ w i) w) w)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5603 (t (throw 'exit t)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5604 i))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5605
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5606 (defun org-renumber-ordered-list (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5607 "Renumber an ordered plain list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5608 Cursor needs to be in the first line of an item, the line that starts
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5609 with something like \"1.\" or \"2)\"."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5610 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5611 (unless (and (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5612 (match-beginning 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5613 (error "This is not an ordered list"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5614 (let ((line (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5615 (col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5616 (ind (org-get-string-indentation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5617 (buffer-substring (point-at-bol) (match-beginning 3))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5618 ;; (term (substring (match-string 3) -1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5619 ind1 (n (1- arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5620 fmt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5621 ;; find where this list begins
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5622 (org-beginning-of-item-list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5623 (looking-at "[ \t]*[0-9]+\\([.)]\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5624 (setq fmt (concat "%d" (match-string 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5625 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5626 ;; walk forward and replace these numbers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5627 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5628 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5629 (catch 'next
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5630 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5631 (if (eobp) (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5632 (if (looking-at "[ \t]*$") (throw 'next nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5633 (skip-chars-forward " \t") (setq ind1 (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5634 (if (> ind1 ind) (throw 'next t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5635 (if (< ind1 ind) (throw 'exit t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5636 (if (not (org-at-item-p)) (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5637 (delete-region (match-beginning 2) (match-end 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5638 (goto-char (match-beginning 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5639 (insert (format fmt (setq n (1+ n)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5640 (goto-line line)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5641 (org-move-to-column col)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5642
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5643 (defun org-fix-bullet-type ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5644 "Make sure all items in this list have the same bullet as the firsst item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5645 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5646 (unless (org-at-item-p) (error "This is not a list"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5647 (let ((line (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5648 (col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5649 (ind (current-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5650 ind1 bullet)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5651 ;; find where this list begins
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5652 (org-beginning-of-item-list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5653 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5654 ;; find out what the bullet type is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5655 (looking-at "[ \t]*\\(\\S-+\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5656 (setq bullet (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5657 ;; walk forward and replace these numbers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5658 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5659 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5660 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5661 (catch 'next
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5662 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5663 (if (eobp) (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5664 (if (looking-at "[ \t]*$") (throw 'next nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5665 (skip-chars-forward " \t") (setq ind1 (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5666 (if (> ind1 ind) (throw 'next t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5667 (if (< ind1 ind) (throw 'exit t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5668 (if (not (org-at-item-p)) (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5669 (skip-chars-forward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5670 (looking-at "\\S-+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5671 (replace-match bullet))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5672 (goto-line line)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5673 (org-move-to-column col)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5674 (if (string-match "[0-9]" bullet)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5675 (org-renumber-ordered-list 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5676
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5677 (defun org-beginning-of-item-list ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5678 "Go to the beginning of the current item list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5679 I.e. to the first item in this list."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5680 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5681 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5682 (let ((pos (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5683 (ind (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5684 ind1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5685 ;; find where this list begins
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5686 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5687 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5688 (catch 'next
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5689 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5690 (if (looking-at "[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5691 (throw (if (bobp) 'exit 'next) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5692 (skip-chars-forward " \t") (setq ind1 (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5693 (if (or (< ind1 ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5694 (and (= ind1 ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5695 (not (org-at-item-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5696 (bobp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5697 (throw 'exit t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5698 (when (org-at-item-p) (setq pos (point-at-bol)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5699 (goto-char pos)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5700
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5701
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5702 (defun org-end-of-item-list ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5703 "Go to the end of the current item list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5704 I.e. to the text after the last item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5705 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5706 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5707 (let ((pos (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5708 (ind (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5709 ind1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5710 ;; find where this list begins
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5711 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5712 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5713 (catch 'next
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5714 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5715 (if (looking-at "[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5716 (throw (if (eobp) 'exit 'next) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5717 (skip-chars-forward " \t") (setq ind1 (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5718 (if (or (< ind1 ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5719 (and (= ind1 ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5720 (not (org-at-item-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5721 (eobp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5722 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5723 (setq pos (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5724 (throw 'exit t))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5725 (goto-char pos)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5726
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5727
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5728 (defvar org-last-indent-begin-marker (make-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5729 (defvar org-last-indent-end-marker (make-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5730
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5731 (defun org-outdent-item (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5732 "Outdent a local list item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5733 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5734 (org-indent-item (- arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5735
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5736 (defun org-indent-item (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5737 "Indent a local list item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5738 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5739 (unless (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5740 (error "Not on an item"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5741 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5742 (let (beg end ind ind1 tmp delta ind-down ind-up)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5743 (if (memq last-command '(org-shiftmetaright org-shiftmetaleft))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5744 (setq beg org-last-indent-begin-marker
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5745 end org-last-indent-end-marker)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5746 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5747 (setq beg (move-marker org-last-indent-begin-marker (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5748 (org-end-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5749 (setq end (move-marker org-last-indent-end-marker (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5750 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5751 (setq tmp (org-item-indent-positions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5752 ind (car tmp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5753 ind-down (nth 2 tmp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5754 ind-up (nth 1 tmp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5755 delta (if (> arg 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5756 (if ind-down (- ind-down ind) 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5757 (if ind-up (- ind-up ind) -2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5758 (if (< (+ delta ind) 0) (error "Cannot outdent beyond margin"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5759 (while (< (point) end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5760 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5761 (skip-chars-forward " \t") (setq ind1 (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5762 (delete-region (point-at-bol) (point))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5763 (or (eolp) (org-indent-to-column (+ ind1 delta)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5764 (beginning-of-line 2))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5765 (org-fix-bullet-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5766 (org-maybe-renumber-ordered-list-safe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5767 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5768 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5769 (condition-case nil (org-beginning-of-item) (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5770 (org-maybe-renumber-ordered-list-safe)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5771
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5772 (defun org-item-indent-positions ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5773 "Return indentation for plain list items.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5774 This returns a list with three values: The current indentation, the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5775 parent indentation and the indentation a child should habe.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5776 Assumes cursor in item line."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5777 (let* ((bolpos (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5778 (ind (org-get-indentation))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5779 ind-down ind-up pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5780 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5781 (org-beginning-of-item-list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5782 (skip-chars-backward "\n\r \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5783 (when (org-in-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5784 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5785 (setq ind-up (org-get-indentation))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5786 (setq pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5787 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5788 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5789 ((and (condition-case nil (progn (org-previous-item) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5790 (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5791 (or (forward-char 1) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5792 (re-search-forward "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)" bolpos t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5793 (setq ind-down (org-get-indentation)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5794 ((and (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5795 (org-at-item-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5796 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5797 (skip-chars-forward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5798 (setq ind-down (current-column)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5799 (list ind ind-up ind-down)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5800
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5801 ;;; The orgstruct minor mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5802
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5803 ;; Define a minor mode which can be used in other modes in order to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5804 ;; integrate the org-mode structure editing commands.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5805
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5806 ;; This is really a hack, because the org-mode structure commands use
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5807 ;; keys which normally belong to the major mode. Here is how it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5808 ;; works: The minor mode defines all the keys necessary to operate the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5809 ;; structure commands, but wraps the commands into a function which
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5810 ;; tests if the cursor is currently at a headline or a plain list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5811 ;; item. If that is the case, the structure command is used,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5812 ;; temporarily setting many Org-mode variables like regular
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5813 ;; expressions for filling etc. However, when any of those keys is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5814 ;; used at a different location, function uses `key-binding' to look
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5815 ;; up if the key has an associated command in another currently active
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5816 ;; keymap (minor modes, major mode, global), and executes that
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5817 ;; command. There might be problems if any of the keys is otherwise
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5818 ;; used as a prefix key.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5819
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5820 ;; Another challenge is that the key binding for TAB can be tab or \C-i,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5821 ;; likewise the binding for RET can be return or \C-m. Orgtbl-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5822 ;; addresses this by checking explicitly for both bindings.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5823
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5824 (defvar orgstruct-mode-map (make-sparse-keymap)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5825 "Keymap for the minor `orgstruct-mode'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5826
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5827 (defvar org-local-vars nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5828 "List of local variables, for use by `orgstruct-mode'")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5829
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5830 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5831 (define-minor-mode orgstruct-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5832 "Toggle the minor more `orgstruct-mode'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5833 This mode is for using Org-mode structure commands in other modes.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5834 The following key behave as if Org-mode was active, if the cursor
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5835 is on a headline, or on a plain list item (both in the definition
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5836 of Org-mode).
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5837
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5838 M-up Move entry/item up
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5839 M-down Move entry/item down
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5840 M-left Promote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5841 M-right Demote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5842 M-S-up Move entry/item up
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5843 M-S-down Move entry/item down
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5844 M-S-left Promote subtree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5845 M-S-right Demote subtree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5846 M-q Fill paragraph and items like in Org-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5847 C-c ^ Sort entries
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5848 C-c - Cycle list bullet
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5849 TAB Cycle item visibility
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5850 M-RET Insert new heading/item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5851 S-M-RET Insert new TODO heading / Chekbox item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5852 C-c C-c Set tags / toggle checkbox"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5853 nil " OrgStruct" nil
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5854 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5855 (and (orgstruct-setup) (defun orgstruct-setup () nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5856
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5857 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5858 (defun turn-on-orgstruct ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5859 "Unconditionally turn on `orgstruct-mode'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5860 (orgstruct-mode 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5861
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5862 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5863 (defun turn-on-orgstruct++ ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5864 "Unconditionally turn on `orgstruct-mode', and force org-mode indentations.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5865 In addition to setting orgstruct-mode, this also exports all indentation and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5866 autofilling variables from org-mode into the buffer. Note that turning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5867 off orgstruct-mode will *not* remove these additional settings."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5868 (orgstruct-mode 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5869 (let (var val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5870 (mapc
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5871 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5872 (when (string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5873 "^\\(paragraph-\\|auto-fill\\|fill-paragraph\\|adaptive-fill\\|indent-\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5874 (symbol-name (car x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5875 (setq var (car x) val (nth 1 x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5876 (org-set-local var (if (eq (car-safe val) 'quote) (nth 1 val) val))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5877 org-local-vars)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5878
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5879 (defun orgstruct-error ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5880 "Error when there is no default binding for a structure key."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5881 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5882 (error "This key has no function outside structure elements"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5883
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5884 (defun orgstruct-setup ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5885 "Setup orgstruct keymaps."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5886 (let ((nfunc 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5887 (bindings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5888 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5889 '([(meta up)] org-metaup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5890 '([(meta down)] org-metadown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5891 '([(meta left)] org-metaleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5892 '([(meta right)] org-metaright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5893 '([(meta shift up)] org-shiftmetaup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5894 '([(meta shift down)] org-shiftmetadown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5895 '([(meta shift left)] org-shiftmetaleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5896 '([(meta shift right)] org-shiftmetaright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5897 '([(shift up)] org-shiftup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5898 '([(shift down)] org-shiftdown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5899 '("\C-c\C-c" org-ctrl-c-ctrl-c)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5900 '("\M-q" fill-paragraph)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5901 '("\C-c^" org-sort)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5902 '("\C-c-" org-cycle-list-bullet)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5903 elt key fun cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5904 (while (setq elt (pop bindings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5905 (setq nfunc (1+ nfunc))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5906 (setq key (org-key (car elt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5907 fun (nth 1 elt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5908 cmd (orgstruct-make-binding fun nfunc key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5909 (org-defkey orgstruct-mode-map key cmd))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5910
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5911 ;; Special treatment needed for TAB and RET
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5912 (org-defkey orgstruct-mode-map [(tab)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5913 (orgstruct-make-binding 'org-cycle 102 [(tab)] "\C-i"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5914 (org-defkey orgstruct-mode-map "\C-i"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5915 (orgstruct-make-binding 'org-cycle 103 "\C-i" [(tab)]))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5916
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5917 (org-defkey orgstruct-mode-map "\M-\C-m"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5918 (orgstruct-make-binding 'org-insert-heading 105
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5919 "\M-\C-m" [(meta return)]))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5920 (org-defkey orgstruct-mode-map [(meta return)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5921 (orgstruct-make-binding 'org-insert-heading 106
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5922 [(meta return)] "\M-\C-m"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5923
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5924 (org-defkey orgstruct-mode-map [(shift meta return)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5925 (orgstruct-make-binding 'org-insert-todo-heading 107
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5926 [(meta return)] "\M-\C-m"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5927
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5928 (unless org-local-vars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5929 (setq org-local-vars (org-get-local-variables)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5930
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5931 t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5932
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5933 (defun orgstruct-make-binding (fun n &rest keys)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5934 "Create a function for binding in the structure minor mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5935 FUN is the command to call inside a table. N is used to create a unique
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5936 command name. KEYS are keys that should be checked in for a command
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5937 to execute outside of tables."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5938 (eval
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5939 (list 'defun
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5940 (intern (concat "orgstruct-hijacker-command-" (int-to-string n)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5941 '(arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5942 (concat "In Structure, run `" (symbol-name fun) "'.\n"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5943 "Outside of structure, run the binding of `"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5944 (mapconcat (lambda (x) (format "%s" x)) keys "' or `")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5945 "'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5946 '(interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5947 (list 'if
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5948 '(org-context-p 'headline 'item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5949 (list 'org-run-like-in-org-mode (list 'quote fun))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5950 (list 'let '(orgstruct-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5951 (list 'call-interactively
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5952 (append '(or)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5953 (mapcar (lambda (k)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5954 (list 'key-binding k))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5955 keys)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5956 '('orgstruct-error))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5957
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5958 (defun org-context-p (&rest contexts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5959 "Check if local context is and of CONTEXTS.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5960 Possible values in the list of contexts are `table', `headline', and `item'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5961 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5962 (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5963 (prog1 (or (and (memq 'table contexts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5964 (looking-at "[ \t]*|"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5965 (and (memq 'headline contexts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5966 (looking-at "\\*+"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5967 (and (memq 'item contexts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5968 (looking-at "[ \t]*\\([-+*] \\|[0-9]+[.)] \\)")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5969 (goto-char pos))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5970
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5971 (defun org-get-local-variables ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5972 "Return a list of all local variables in an org-mode buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5973 (let (varlist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5974 (with-current-buffer (get-buffer-create "*Org tmp*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5975 (erase-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5976 (org-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5977 (setq varlist (buffer-local-variables)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5978 (kill-buffer "*Org tmp*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5979 (delq nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5980 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5981 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5982 (setq x
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5983 (if (symbolp x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5984 (list x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5985 (list (car x) (list 'quote (cdr x)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5986 (if (string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5987 "^\\(org-\\|orgtbl-\\|outline-\\|comment-\\|paragraph-\\|auto-fill\\|fill-paragraph\\|adaptive-fill\\|indent-\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5988 (symbol-name (car x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5989 x nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5990 varlist))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5991
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5992 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5993 (defun org-run-like-in-org-mode (cmd)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5994 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5995 (unless org-local-vars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5996 (setq org-local-vars (org-get-local-variables)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5997 (eval (list 'let org-local-vars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5998 (list 'call-interactively (list 'quote cmd)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5999
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6000 ;;;; Archiving
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6001
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6002 (defun org-get-category (&optional pos)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6003 "Get the category applying to position POS."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6004 (get-text-property (or pos (point)) 'org-category))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6005
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6006 (defun org-refresh-category-properties ()
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6007 "Refresh category text properties in the buffer."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6008 (let ((def-cat (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6009 ((null org-category)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6010 (if buffer-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6011 (file-name-sans-extension
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6012 (file-name-nondirectory buffer-file-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6013 "???"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6014 ((symbolp org-category) (symbol-name org-category))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6015 (t org-category)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6016 beg end cat pos optionp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6017 (org-unmodified
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6018 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6019 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6020 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6021 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6022 (put-text-property (point) (point-max) 'org-category def-cat)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6023 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6024 "^\\(#\\+CATEGORY:\\|[ \t]*:CATEGORY:\\)\\(.*\\)" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6025 (setq pos (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6026 optionp (equal (char-after (match-beginning 0)) ?#)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6027 cat (org-trim (match-string 2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6028 (if optionp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6029 (setq beg (point-at-bol) end (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6030 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6031 (setq beg (point) end (org-end-of-subtree t t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6032 (put-text-property beg end 'org-category cat)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6033 (goto-char pos)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6034
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6035
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6036 ;;;; Link Stuff
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6037
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6038 ;;; Link abbreviations
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6039
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6040 (defun org-link-expand-abbrev (link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6041 "Apply replacements as defined in `org-link-abbrev-alist."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6042 (if (string-match "^\\([a-zA-Z][-_a-zA-Z0-9]*\\)\\(::?\\(.*\\)\\)?$" link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6043 (let* ((key (match-string 1 link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6044 (as (or (assoc key org-link-abbrev-alist-local)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6045 (assoc key org-link-abbrev-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6046 (tag (and (match-end 2) (match-string 3 link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6047 rpl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6048 (if (not as)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6049 link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6050 (setq rpl (cdr as))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6051 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6052 ((symbolp rpl) (funcall rpl tag))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6053 ((string-match "%s" rpl) (replace-match (or tag "") t t rpl))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6054 (t (concat rpl tag)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6055 link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6056
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6057 ;;; Storing and inserting links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6058
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6059 (defvar org-insert-link-history nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6060 "Minibuffer history for links inserted with `org-insert-link'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6061
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6062 (defvar org-stored-links nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6063 "Contains the links stored with `org-store-link'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6064
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6065 (defvar org-store-link-plist nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6066 "Plist with info about the most recently link created with `org-store-link'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6067
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6068 (defvar org-link-protocols nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6069 "Link protocols added to Org-mode using `org-add-link-type'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6070
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6071 (defvar org-store-link-functions nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6072 "List of functions that are called to create and store a link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6073 Each function will be called in turn until one returns a non-nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6074 value. Each function should check if it is responsible for creating
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6075 this link (for example by looking at the major mode).
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6076 If not, it must exit and return nil.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6077 If yes, it should return a non-nil value after a calling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6078 `org-store-link-props' with a list of properties and values.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6079 Special properties are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6080
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6081 :type The link prefix. like \"http\". This must be given.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6082 :link The link, like \"http://www.astro.uva.nl/~dominik\".
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6083 This is obligatory as well.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6084 :description Optional default description for the second pair
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6085 of brackets in an Org-mode link. The user can still change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6086 this when inserting this link into an Org-mode buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6087
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6088 In addition to these, any additional properties can be specified
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6089 and then used in remember templates.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6090
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6091 (defun org-add-link-type (type &optional follow export)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6092 "Add TYPE to the list of `org-link-types'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6093 Re-compute all regular expressions depending on `org-link-types'
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6094
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6095 FOLLOW and EXPORT are two functions.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6096
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6097 FOLLOW should take the link path as the single argument and do whatever
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6098 is necessary to follow the link, for example find a file or display
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6099 a mail message.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6100
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6101 EXPORT should format the link path for export to one of the export formats.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6102 It should be a function accepting three arguments:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6103
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6104 path the path of the link, the text after the prefix (like \"http:\")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6105 desc the description of the link, if any, nil if there was no descripton
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6106 format the export format, a symbol like `html' or `latex'.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6107
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6108 The function may use the FORMAT information to return different values
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6109 depending on the format. The return value will be put literally into
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6110 the exported file.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6111 Org-mode has a built-in default for exporting links. If you are happy with
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6112 this default, there is no need to define an export function for the link
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6113 type. For a simple example of an export function, see `org-bbdb.el'."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6114 (add-to-list 'org-link-types type t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6115 (org-make-link-regexps)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6116 (if (assoc type org-link-protocols)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6117 (setcdr (assoc type org-link-protocols) (list follow export))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6118 (push (list type follow export) org-link-protocols)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6119
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6120
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6121 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6122 (defun org-store-link (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6123 "\\<org-mode-map>Store an org-link to the current location.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6124 This link is added to `org-stored-links' and can later be inserted
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6125 into an org-buffer with \\[org-insert-link].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6126
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6127 For some link types, a prefix arg is interpreted:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6128 For links to usenet articles, arg negates `org-usenet-links-prefer-google'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6129 For file links, arg negates `org-context-in-file-links'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6130 (interactive "P")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6131 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6132 (setq org-store-link-plist nil) ; reset
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6133 (let (link cpltxt desc description search txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6134 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6135
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6136 ((run-hook-with-args-until-success 'org-store-link-functions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6137 (setq link (plist-get org-store-link-plist :link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6138 desc (or (plist-get org-store-link-plist :description) link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6139
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6140 ((eq major-mode 'calendar-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6141 (let ((cd (calendar-cursor-to-date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6142 (setq link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6143 (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6144 (car org-time-stamp-formats)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6145 (apply 'encode-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6146 (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6147 nil nil nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6148 (org-store-link-props :type "calendar" :date cd)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6149
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6150 ((eq major-mode 'w3-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6151 (setq cpltxt (url-view-url t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6152 link (org-make-link cpltxt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6153 (org-store-link-props :type "w3" :url (url-view-url t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6154
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6155 ((eq major-mode 'w3m-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6156 (setq cpltxt (or w3m-current-title w3m-current-url)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6157 link (org-make-link w3m-current-url))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6158 (org-store-link-props :type "w3m" :url (url-view-url t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6159
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6160 ((setq search (run-hook-with-args-until-success
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6161 'org-create-file-search-functions))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6162 (setq link (concat "file:" (abbreviate-file-name buffer-file-name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6163 "::" search))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6164 (setq cpltxt (or description link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6165
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6166 ((eq major-mode 'image-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6167 (setq cpltxt (concat "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6168 (abbreviate-file-name buffer-file-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6169 link (org-make-link cpltxt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6170 (org-store-link-props :type "image" :file buffer-file-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6171
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6172 ((eq major-mode 'dired-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6173 ;; link to the file in the current line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6174 (setq cpltxt (concat "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6175 (abbreviate-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6176 (expand-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6177 (dired-get-filename nil t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6178 link (org-make-link cpltxt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6179
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6180 ((and buffer-file-name (org-mode-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6181 ;; Just link to current headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6182 (setq cpltxt (concat "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6183 (abbreviate-file-name buffer-file-name)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6184 ;; Add a context search string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6185 (when (org-xor org-context-in-file-links arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6186 ;; Check if we are on a target
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6187 (if (org-in-regexp "<<\\(.*?\\)>>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6188 (setq cpltxt (concat cpltxt "::" (match-string 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6189 (setq txt (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6190 ((org-on-heading-p) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6191 ((org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6192 (buffer-substring (region-beginning) (region-end)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6193 (t nil)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6194 (when (or (null txt) (string-match "\\S-" txt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6195 (setq cpltxt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6196 (concat cpltxt "::" (org-make-org-heading-search-string txt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6197 desc "NONE"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6198 (if (string-match "::\\'" cpltxt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6199 (setq cpltxt (substring cpltxt 0 -2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6200 (setq link (org-make-link cpltxt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6201
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6202 ((buffer-file-name (buffer-base-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6203 ;; Just link to this file here.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6204 (setq cpltxt (concat "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6205 (abbreviate-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6206 (buffer-file-name (buffer-base-buffer)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6207 ;; Add a context string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6208 (when (org-xor org-context-in-file-links arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6209 (setq txt (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6210 (buffer-substring (region-beginning) (region-end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6211 (buffer-substring (point-at-bol) (point-at-eol))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6212 ;; Only use search option if there is some text.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6213 (when (string-match "\\S-" txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6214 (setq cpltxt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6215 (concat cpltxt "::" (org-make-org-heading-search-string txt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6216 desc "NONE")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6217 (setq link (org-make-link cpltxt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6218
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6219 ((interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6220 (error "Cannot link to a buffer which is not visiting a file"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6221
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6222 (t (setq link nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6223
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6224 (if (consp link) (setq cpltxt (car link) link (cdr link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6225 (setq link (or link cpltxt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6226 desc (or desc cpltxt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6227 (if (equal desc "NONE") (setq desc nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6228
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6229 (if (and (interactive-p) link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6230 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6231 (setq org-stored-links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6232 (cons (list link desc) org-stored-links))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6233 (message "Stored: %s" (or desc link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6234 (and link (org-make-link-string link desc)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6235
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6236 (defun org-store-link-props (&rest plist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6237 "Store link properties, extract names and addresses."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6238 (let (x adr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6239 (when (setq x (plist-get plist :from))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6240 (setq adr (mail-extract-address-components x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6241 (plist-put plist :fromname (car adr))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6242 (plist-put plist :fromaddress (nth 1 adr)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6243 (when (setq x (plist-get plist :to))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6244 (setq adr (mail-extract-address-components x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6245 (plist-put plist :toname (car adr))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6246 (plist-put plist :toaddress (nth 1 adr))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6247 (let ((from (plist-get plist :from))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6248 (to (plist-get plist :to)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6249 (when (and from to org-from-is-user-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6250 (plist-put plist :fromto
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6251 (if (string-match org-from-is-user-regexp from)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6252 (concat "to %t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6253 (concat "from %f")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6254 (setq org-store-link-plist plist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6255
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6256 (defun org-add-link-props (&rest plist)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6257 "Add these properties to the link property list."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6258 (let (key value)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6259 (while plist
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6260 (setq key (pop plist) value (pop plist))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6261 (setq org-store-link-plist
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6262 (plist-put org-store-link-plist key value)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6263
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6264 (defun org-email-link-description (&optional fmt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6265 "Return the description part of an email link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6266 This takes information from `org-store-link-plist' and formats it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6267 according to FMT (default from `org-email-link-description-format')."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6268 (setq fmt (or fmt org-email-link-description-format))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6269 (let* ((p org-store-link-plist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6270 (to (plist-get p :toaddress))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6271 (from (plist-get p :fromaddress))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6272 (table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6273 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6274 (cons "%c" (plist-get p :fromto))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6275 (cons "%F" (plist-get p :from))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6276 (cons "%f" (or (plist-get p :fromname) (plist-get p :fromaddress) "?"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6277 (cons "%T" (plist-get p :to))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6278 (cons "%t" (or (plist-get p :toname) (plist-get p :toaddress) "?"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6279 (cons "%s" (plist-get p :subject))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6280 (cons "%m" (plist-get p :message-id)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6281 (when (string-match "%c" fmt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6282 ;; Check if the user wrote this message
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6283 (if (and org-from-is-user-regexp from to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6284 (save-match-data (string-match org-from-is-user-regexp from)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6285 (setq fmt (replace-match "to %t" t t fmt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6286 (setq fmt (replace-match "from %f" t t fmt))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6287 (org-replace-escapes fmt table)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6288
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6289 (defun org-make-org-heading-search-string (&optional string heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6290 "Make search string for STRING or current headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6291 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6292 (let ((s (or string (org-get-heading))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6293 (unless (and string (not heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6294 ;; We are using a headline, clean up garbage in there.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6295 (if (string-match org-todo-regexp s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6296 (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6297 (if (string-match (org-re ":[[:alnum:]_@:]+:[ \t]*$") s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6298 (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6299 (setq s (org-trim s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6300 (if (string-match (concat "^\\(" org-quote-string "\\|"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6301 org-comment-string "\\)") s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6302 (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6303 (while (string-match org-ts-regexp s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6304 (setq s (replace-match "" t t s))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6305 (while (string-match "[^a-zA-Z_0-9 \t]+" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6306 (setq s (replace-match " " t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6307 (or string (setq s (concat "*" s))) ; Add * for headlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6308 (mapconcat 'identity (org-split-string s "[ \t]+") " ")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6309
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6310 (defun org-make-link (&rest strings)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6311 "Concatenate STRINGS."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6312 (apply 'concat strings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6313
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6314 (defun org-make-link-string (link &optional description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6315 "Make a link with brackets, consisting of LINK and DESCRIPTION."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6316 (unless (string-match "\\S-" link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6317 (error "Empty link"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6318 (when (stringp description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6319 ;; Remove brackets from the description, they are fatal.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6320 (while (string-match "\\[" description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6321 (setq description (replace-match "{" t t description)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6322 (while (string-match "\\]" description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6323 (setq description (replace-match "}" t t description))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6324 (when (equal (org-link-escape link) description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6325 ;; No description needed, it is identical
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6326 (setq description nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6327 (when (and (not description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6328 (not (equal link (org-link-escape link))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6329 (setq description link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6330 (concat "[[" (org-link-escape link) "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6331 (if description (concat "[" description "]") "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6332 "]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6333
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6334 (defconst org-link-escape-chars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6335 '((?\ . "%20")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6336 (?\[ . "%5B")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6337 (?\] . "%5D")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6338 (?\340 . "%E0") ; `a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6339 (?\342 . "%E2") ; ^a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6340 (?\347 . "%E7") ; ,c
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6341 (?\350 . "%E8") ; `e
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6342 (?\351 . "%E9") ; 'e
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6343 (?\352 . "%EA") ; ^e
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6344 (?\356 . "%EE") ; ^i
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6345 (?\364 . "%F4") ; ^o
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6346 (?\371 . "%F9") ; `u
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6347 (?\373 . "%FB") ; ^u
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6348 (?\; . "%3B")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6349 (?? . "%3F")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6350 (?= . "%3D")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6351 (?+ . "%2B")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6352 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6353 "Association list of escapes for some characters problematic in links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6354 This is the list that is used for internal purposes.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6355
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6356 (defconst org-link-escape-chars-browser
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6357 '((?\ . "%20")) ; 32 for the SPC char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6358 "Association list of escapes for some characters problematic in links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6359 This is the list that is used before handing over to the browser.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6360
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6361 (defun org-link-escape (text &optional table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6362 "Escape charaters in TEXT that are problematic for links."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6363 (setq table (or table org-link-escape-chars))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6364 (when text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6365 (let ((re (mapconcat (lambda (x) (regexp-quote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6366 (char-to-string (car x))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6367 table "\\|")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6368 (while (string-match re text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6369 (setq text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6370 (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6371 (cdr (assoc (string-to-char (match-string 0 text))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6372 table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6373 t t text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6374 text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6375
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6376 (defun org-link-unescape (text &optional table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6377 "Reverse the action of `org-link-escape'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6378 (setq table (or table org-link-escape-chars))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6379 (when text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6380 (let ((re (mapconcat (lambda (x) (regexp-quote (cdr x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6381 table "\\|")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6382 (while (string-match re text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6383 (setq text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6384 (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6385 (char-to-string (car (rassoc (match-string 0 text) table)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6386 t t text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6387 text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6388
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6389 (defun org-xor (a b)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6390 "Exclusive or."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6391 (if a (not b) b))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6392
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6393 (defun org-get-header (header)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6394 "Find a header field in the current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6395 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6396 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6397 (let ((case-fold-search t) s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6398 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6399 ((eq header 'from)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6400 (if (re-search-forward "^From:\\s-+\\(.*\\)" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6401 (setq s (match-string 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6402 (while (string-match "\"" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6403 (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6404 (if (string-match "[<(].*" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6405 (setq s (replace-match "" t t s))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6406 ((eq header 'message-id)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6407 (if (re-search-forward "^message-id:\\s-+\\(.*\\)" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6408 (setq s (match-string 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6409 ((eq header 'subject)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6410 (if (re-search-forward "^subject:\\s-+\\(.*\\)" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6411 (setq s (match-string 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6412 (if (string-match "\\`[ \t\]+" s) (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6413 (if (string-match "[ \t\]+\\'" s) (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6414 s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6415
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6416
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6417 (defun org-fixup-message-id-for-http (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6418 "Replace special characters in a message id, so it can be used in an http query."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6419 (while (string-match "<" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6420 (setq s (replace-match "%3C" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6421 (while (string-match ">" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6422 (setq s (replace-match "%3E" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6423 (while (string-match "@" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6424 (setq s (replace-match "%40" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6425 s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6426
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6427 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6428 (defun org-insert-link-global ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6429 "Insert a link like Org-mode does.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6430 This command can be called in any mode to insert a link in Org-mode syntax."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6431 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6432 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6433 (org-run-like-in-org-mode 'org-insert-link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6434
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6435 (defun org-insert-link (&optional complete-file link-location)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6436 "Insert a link. At the prompt, enter the link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6437
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6438 Completion can be used to select a link previously stored with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6439 `org-store-link'. When the empty string is entered (i.e. if you just
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6440 press RET at the prompt), the link defaults to the most recently
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6441 stored link. As SPC triggers completion in the minibuffer, you need to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6442 use M-SPC or C-q SPC to force the insertion of a space character.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6443
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6444 You will also be prompted for a description, and if one is given, it will
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6445 be displayed in the buffer instead of the link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6446
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6447 If there is already a link at point, this command will allow you to edit link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6448 and description parts.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6449
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6450 With a \\[universal-argument] prefix, prompts for a file to link to. The file name can
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6451 be selected using completion. The path to the file will be relative to the
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6452 current directory if the file is in the current directory or a subdirectory.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6453 Otherwise, the link will be the absolute path as completed in the minibuffer
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6454 \(i.e. normally ~/path/to/file).
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6455
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6456 With two \\[universal-argument] prefixes, enforce an absolute path even if the file is in
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6457 the current directory or below. With three \\[universal-argument] prefixes, negate the meaning
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6458 of `org-keep-stored-link-after-insertion'.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6459
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6460 If `org-make-link-description-function' is non-nil, this function will be
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6461 called with the link target, and the result will be the default
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6462 link description.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6463
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6464 If the LINK-LOCATION parameter is non-nil, this value will be
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6465 used as the link location instead of reading one interactively."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6466 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6467 (let* ((wcf (current-window-configuration))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6468 (region (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6469 (buffer-substring (region-beginning) (region-end))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6470 (remove (and region (list (region-beginning) (region-end))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6471 (desc region)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6472 tmphist ; byte-compile incorrectly complains about this
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6473 (link link-location)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6474 entry file)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6475 (cond
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6476 (link-location) ; specified by arg, just use it.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6477 ((org-in-regexp org-bracket-link-regexp 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6478 ;; We do have a link at point, and we are going to edit it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6479 (setq remove (list (match-beginning 0) (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6480 (setq desc (if (match-end 3) (org-match-string-no-properties 3)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6481 (setq link (read-string "Link: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6482 (org-link-unescape
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6483 (org-match-string-no-properties 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6484 ((or (org-in-regexp org-angle-link-re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6485 (org-in-regexp org-plain-link-re))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6486 ;; Convert to bracket link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6487 (setq remove (list (match-beginning 0) (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6488 link (read-string "Link: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6489 (org-remove-angle-brackets (match-string 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6490 ((equal complete-file '(4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6491 ;; Completing read for file names.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6492 (setq file (read-file-name "File: "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6493 (let ((pwd (file-name-as-directory (expand-file-name ".")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6494 (pwd1 (file-name-as-directory (abbreviate-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6495 (expand-file-name ".")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6496 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6497 ((equal complete-file '(16))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6498 (setq link (org-make-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6499 "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6500 (abbreviate-file-name (expand-file-name file)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6501 ((string-match (concat "^" (regexp-quote pwd1) "\\(.+\\)") file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6502 (setq link (org-make-link "file:" (match-string 1 file))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6503 ((string-match (concat "^" (regexp-quote pwd) "\\(.+\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6504 (expand-file-name file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6505 (setq link (org-make-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6506 "file:" (match-string 1 (expand-file-name file)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6507 (t (setq link (org-make-link "file:" file))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6508 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6509 ;; Read link, with completion for stored links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6510 (with-output-to-temp-buffer "*Org Links*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6511 (princ "Insert a link. Use TAB to complete valid link prefixes.\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6512 (when org-stored-links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6513 (princ "\nStored links are available with <up>/<down> or M-p/n (most recent with RET):\n\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6514 (princ (mapconcat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6515 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6516 (if (nth 1 x) (concat (car x) " (" (nth 1 x) ")") (car x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6517 (reverse org-stored-links) "\n"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6518 (let ((cw (selected-window)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6519 (select-window (get-buffer-window "*Org Links*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6520 (shrink-window-if-larger-than-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6521 (setq truncate-lines t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6522 (select-window cw))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6523 ;; Fake a link history, containing the stored links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6524 (setq tmphist (append (mapcar 'car org-stored-links)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6525 org-insert-link-history))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6526 (unwind-protect
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6527 (setq link (org-completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6528 "Link: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6529 (append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6530 (mapcar (lambda (x) (list (concat (car x) ":")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6531 (append org-link-abbrev-alist-local org-link-abbrev-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6532 (mapcar (lambda (x) (list (concat x ":")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6533 org-link-types))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6534 nil nil nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6535 'tmphist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6536 (or (car (car org-stored-links)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6537 (set-window-configuration wcf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6538 (kill-buffer "*Org Links*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6539 (setq entry (assoc link org-stored-links))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6540 (or entry (push link org-insert-link-history))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6541 (if (funcall (if (equal complete-file '(64)) 'not 'identity)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6542 (not org-keep-stored-link-after-insertion))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6543 (setq org-stored-links (delq (assoc link org-stored-links)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6544 org-stored-links)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6545 (setq desc (or desc (nth 1 entry)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6546
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6547 (if (string-match org-plain-link-re link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6548 ;; URL-like link, normalize the use of angular brackets.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6549 (setq link (org-make-link (org-remove-angle-brackets link))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6550
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6551 ;; Check if we are linking to the current file with a search option
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6552 ;; If yes, simplify the link by using only the search option.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6553 (when (and buffer-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6554 (string-match "\\<file:\\(.+?\\)::\\([^>]+\\)" link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6555 (let* ((path (match-string 1 link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6556 (case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6557 (search (match-string 2 link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6558 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6559 (if (equal (file-truename buffer-file-name) (file-truename path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6560 ;; We are linking to this same file, with a search option
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6561 (setq link search)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6562
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6563 ;; Check if we can/should use a relative path. If yes, simplify the link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6564 (when (string-match "\\<file:\\(.*\\)" link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6565 (let* ((path (match-string 1 link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6566 (origpath path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6567 (case-fold-search nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6568 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6569 ((eq org-link-file-path-type 'absolute)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6570 (setq path (abbreviate-file-name (expand-file-name path))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6571 ((eq org-link-file-path-type 'noabbrev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6572 (setq path (expand-file-name path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6573 ((eq org-link-file-path-type 'relative)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6574 (setq path (file-relative-name path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6575 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6576 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6577 (if (string-match (concat "^" (regexp-quote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6578 (file-name-as-directory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6579 (expand-file-name "."))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6580 (expand-file-name path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6581 ;; We are linking a file with relative path name.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6582 (setq path (substring (expand-file-name path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6583 (match-end 0)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6584 (setq link (concat "file:" path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6585 (if (equal desc origpath)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6586 (setq desc path))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6587
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6588 (if org-make-link-description-function
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6589 (setq desc (funcall org-make-link-description-function link desc)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6590
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6591 (setq desc (read-string "Description: " desc))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6592 (unless (string-match "\\S-" desc) (setq desc nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6593 (if remove (apply 'delete-region remove))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6594 (insert (org-make-link-string link desc))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6595
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6596 (defun org-completing-read (&rest args)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6597 (let ((minibuffer-local-completion-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6598 (copy-keymap minibuffer-local-completion-map)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6599 (org-defkey minibuffer-local-completion-map " " 'self-insert-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6600 (apply 'completing-read args)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6601
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6602 ;;; Opening/following a link
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6603
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6604 (defvar org-link-search-failed nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6605
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6606 (defun org-next-link ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6607 "Move forward to the next link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6608 If the link is in hidden text, expose it."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6609 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6610 (when (and org-link-search-failed (eq this-command last-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6611 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6612 (message "Link search wrapped back to beginning of buffer"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6613 (setq org-link-search-failed nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6614 (let* ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6615 (ct (org-context))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6616 (a (assoc :link ct)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6617 (if a (goto-char (nth 2 a)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6618 (if (re-search-forward org-any-link-re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6619 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6620 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6621 (if (org-invisible-p) (org-show-context)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6622 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6623 (setq org-link-search-failed t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6624 (error "No further link found"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6625
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6626 (defun org-previous-link ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6627 "Move backward to the previous link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6628 If the link is in hidden text, expose it."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6629 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6630 (when (and org-link-search-failed (eq this-command last-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6631 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6632 (message "Link search wrapped back to end of buffer"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6633 (setq org-link-search-failed nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6634 (let* ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6635 (ct (org-context))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6636 (a (assoc :link ct)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6637 (if a (goto-char (nth 1 a)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6638 (if (re-search-backward org-any-link-re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6639 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6640 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6641 (if (org-invisible-p) (org-show-context)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6642 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6643 (setq org-link-search-failed t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6644 (error "No further link found"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6645
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6646 (defun org-find-file-at-mouse (ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6647 "Open file link or URL at mouse."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6648 (interactive "e")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6649 (mouse-set-point ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6650 (org-open-at-point 'in-emacs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6651
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6652 (defun org-open-at-mouse (ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6653 "Open file link or URL at mouse."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6654 (interactive "e")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6655 (mouse-set-point ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6656 (org-open-at-point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6657
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6658 (defvar org-window-config-before-follow-link nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6659 "The window configuration before following a link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6660 This is saved in case the need arises to restore it.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6661
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6662 (defvar org-open-link-marker (make-marker)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6663 "Marker pointing to the location where `org-open-at-point; was called.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6664
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6665 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6666 (defun org-open-at-point-global ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6667 "Follow a link like Org-mode does.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6668 This command can be called in any mode to follow a link that has
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6669 Org-mode syntax."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6670 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6671 (org-run-like-in-org-mode 'org-open-at-point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6672
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6673 ;;;###autoload
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6674 (defun org-open-link-from-string (s &optional arg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6675 "Open a link in the string S, as if it was in Org-mode."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6676 (interactive "sLink: \nP")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6677 (with-temp-buffer
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6678 (let ((org-inhibit-startup t))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6679 (org-mode)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6680 (insert s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6681 (goto-char (point-min))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6682 (org-open-at-point arg))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6683
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6684 (defun org-open-at-point (&optional in-emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6685 "Open link at or after point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6686 If there is no link at point, this function will search forward up to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6687 the end of the current subtree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6688 Normally, files will be opened by an appropriate application. If the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6689 optional argument IN-EMACS is non-nil, Emacs will visit the file."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6690 (interactive "P")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6691 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6692 (move-marker org-open-link-marker (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6693 (setq org-window-config-before-follow-link (current-window-configuration))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6694 (org-remove-occur-highlights nil nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6695 (if (org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6696 (org-follow-timestamp-link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6697 (let (type path link line search (pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6698 (catch 'match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6699 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6700 (skip-chars-forward "^]\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6701 (when (org-in-regexp org-bracket-link-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6702 (setq link (org-link-unescape (org-match-string-no-properties 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6703 (while (string-match " *\n *" link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6704 (setq link (replace-match " " t t link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6705 (setq link (org-link-expand-abbrev link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6706 (if (string-match org-link-re-with-space2 link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6707 (setq type (match-string 1 link) path (match-string 2 link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6708 (setq type "thisfile" path link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6709 (throw 'match t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6710
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6711 (when (get-text-property (point) 'org-linked-text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6712 (setq type "thisfile"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6713 pos (if (get-text-property (1+ (point)) 'org-linked-text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6714 (1+ (point)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6715 path (buffer-substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6716 (previous-single-property-change pos 'org-linked-text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6717 (next-single-property-change pos 'org-linked-text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6718 (throw 'match t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6719
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6720 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6721 (when (or (org-in-regexp org-angle-link-re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6722 (org-in-regexp org-plain-link-re))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6723 (setq type (match-string 1) path (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6724 (throw 'match t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6725 (when (org-in-regexp "\\<\\([^><\n]+\\)\\>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6726 (setq type "tree-match"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6727 path (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6728 (throw 'match t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6729 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6730 (when (org-in-regexp (org-re "\\(:[[:alnum:]_@:]+\\):[ \t]*$"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6731 (setq type "tags"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6732 path (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6733 (while (string-match ":" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6734 (setq path (replace-match "+" t t path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6735 (throw 'match t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6736 (unless path
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6737 (error "No link found"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6738 ;; Remove any trailing spaces in path
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6739 (if (string-match " +\\'" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6740 (setq path (replace-match "" t t path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6741
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6742 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6743
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6744 ((assoc type org-link-protocols)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6745 (funcall (nth 1 (assoc type org-link-protocols)) path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6746
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6747 ((equal type "mailto")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6748 (let ((cmd (car org-link-mailto-program))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6749 (args (cdr org-link-mailto-program)) args1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6750 (address path) (subject "") a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6751 (if (string-match "\\(.*\\)::\\(.*\\)" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6752 (setq address (match-string 1 path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6753 subject (org-link-escape (match-string 2 path))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6754 (while args
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6755 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6756 ((not (stringp (car args))) (push (pop args) args1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6757 (t (setq a (pop args))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6758 (if (string-match "%a" a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6759 (setq a (replace-match address t t a)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6760 (if (string-match "%s" a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6761 (setq a (replace-match subject t t a)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6762 (push a args1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6763 (apply cmd (nreverse args1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6764
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6765 ((member type '("http" "https" "ftp" "news"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6766 (browse-url (concat type ":" (org-link-escape
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6767 path org-link-escape-chars-browser))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6768
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6769 ((member type '("message"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6770 (browse-url (concat type ":" path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6771
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6772 ((string= type "tags")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6773 (org-tags-view in-emacs path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6774 ((string= type "thisfile")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6775 (if in-emacs
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6776 (switch-to-buffer-other-window
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6777 (org-get-buffer-for-internal-link (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6778 (org-mark-ring-push))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6779 (let ((cmd `(org-link-search
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6780 ,path
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6781 ,(cond ((equal in-emacs '(4)) 'occur)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6782 ((equal in-emacs '(16)) 'org-occur)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6783 (t nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6784 ,pos)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6785 (condition-case nil (eval cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6786 (error (progn (widen) (eval cmd))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6787
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6788 ((string= type "tree-match")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6789 (org-occur (concat "\\[" (regexp-quote path) "\\]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6790
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6791 ((string= type "file")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6792 (if (string-match "::\\([0-9]+\\)\\'" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6793 (setq line (string-to-number (match-string 1 path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6794 path (substring path 0 (match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6795 (if (string-match "::\\(.+\\)\\'" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6796 (setq search (match-string 1 path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6797 path (substring path 0 (match-beginning 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6798 (if (string-match "[*?{]" (file-name-nondirectory path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6799 (dired path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6800 (org-open-file path in-emacs line search)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6801
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6802 ((string= type "news")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6803 (require 'org-gnus)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6804 (org-gnus-follow-link path))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6805
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6806 ((string= type "shell")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6807 (let ((cmd path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6808 (if (or (not org-confirm-shell-link-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6809 (funcall org-confirm-shell-link-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6810 (format "Execute \"%s\" in shell? "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6811 (org-add-props cmd nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6812 'face 'org-warning))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6813 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6814 (message "Executing %s" cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6815 (shell-command cmd))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6816 (error "Abort"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6817
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6818 ((string= type "elisp")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6819 (let ((cmd path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6820 (if (or (not org-confirm-elisp-link-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6821 (funcall org-confirm-elisp-link-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6822 (format "Execute \"%s\" as elisp? "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6823 (org-add-props cmd nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6824 'face 'org-warning))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6825 (message "%s => %s" cmd (eval (read cmd)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6826 (error "Abort"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6827
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6828 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6829 (browse-url-at-point)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6830 (move-marker org-open-link-marker nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6831 (run-hook-with-args 'org-follow-link-hook))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6832
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6833 ;;;; Time estimates
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6834
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6835 (defun org-get-effort (&optional pom)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6836 "Get the effort estimate for the current entry."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6837 (org-entry-get pom org-effort-property))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6838
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6839 ;;; File search
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6840
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6841 (defvar org-create-file-search-functions nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6842 "List of functions to construct the right search string for a file link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6843 These functions are called in turn with point at the location to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6844 which the link should point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6845
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6846 A function in the hook should first test if it would like to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6847 handle this file type, for example by checking the major-mode or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6848 the file extension. If it decides not to handle this file, it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6849 should just return nil to give other functions a chance. If it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6850 does handle the file, it must return the search string to be used
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6851 when following the link. The search string will be part of the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6852 file link, given after a double colon, and `org-open-at-point'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6853 will automatically search for it. If special measures must be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6854 taken to make the search successful, another function should be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6855 added to the companion hook `org-execute-file-search-functions',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6856 which see.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6857
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6858 A function in this hook may also use `setq' to set the variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6859 `description' to provide a suggestion for the descriptive text to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6860 be used for this link when it gets inserted into an Org-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6861 buffer with \\[org-insert-link].")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6862
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6863 (defvar org-execute-file-search-functions nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6864 "List of functions to execute a file search triggered by a link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6865
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6866 Functions added to this hook must accept a single argument, the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6867 search string that was part of the file link, the part after the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6868 double colon. The function must first check if it would like to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6869 handle this search, for example by checking the major-mode or the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6870 file extension. If it decides not to handle this search, it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6871 should just return nil to give other functions a chance. If it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6872 does handle the search, it must return a non-nil value to keep
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6873 other functions from trying.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6874
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6875 Each function can access the current prefix argument through the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6876 variable `current-prefix-argument'. Note that a single prefix is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6877 used to force opening a link in Emacs, so it may be good to only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6878 use a numeric or double prefix to guide the search function.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6879
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6880 In case this is needed, a function in this hook can also restore
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6881 the window configuration before `org-open-at-point' was called using:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6882
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6883 (set-window-configuration org-window-config-before-follow-link)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6884
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6885 (defun org-link-search (s &optional type avoid-pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6886 "Search for a link search option.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6887 If S is surrounded by forward slashes, it is interpreted as a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6888 regular expression. In org-mode files, this will create an `org-occur'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6889 sparse tree. In ordinary files, `occur' will be used to list matches.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6890 If the current buffer is in `dired-mode', grep will be used to search
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6891 in all files. If AVOID-POS is given, ignore matches near that position."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6892 (let ((case-fold-search t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6893 (s0 (mapconcat 'identity (org-split-string s "[ \t\r\n]+") " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6894 (markers (concat "\\(?:" (mapconcat (lambda (x) (regexp-quote (car x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6895 (append '(("") (" ") ("\t") ("\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6896 org-emphasis-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6897 "\\|") "\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6898 (pos (point))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6899 (pre nil) (post nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6900 words re0 re1 re2 re3 re4_ re4 re5 re2a re2a_ reall)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6901 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6902 ;; First check if there are any special
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6903 ((run-hook-with-args-until-success 'org-execute-file-search-functions s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6904 ;; Now try the builtin stuff
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6905 ((save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6906 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6907 (and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6908 (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6909 (concat "<<" (regexp-quote s0) ">>") nil t)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6910 (setq type 'dedicated
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6911 pos (match-beginning 0))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6912 ;; There is an exact target for this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6913 (goto-char pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6914 ((string-match "^/\\(.*\\)/$" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6915 ;; A regular expression
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6916 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6917 ((org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6918 (org-occur (match-string 1 s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6919 ;;((eq major-mode 'dired-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6920 ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6921 (t (org-do-occur (match-string 1 s)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6922 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6923 ;; A normal search strings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6924 (when (equal (string-to-char s) ?*)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6925 ;; Anchor on headlines, post may include tags.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6926 (setq pre "^\\*+[ \t]+\\(?:\\sw+\\)?[ \t]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6927 post (org-re "[ \t]*\\(?:[ \t]+:[[:alnum:]_@:+]:[ \t]*\\)?$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6928 s (substring s 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6929 (remove-text-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6930 0 (length s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6931 '(face nil mouse-face nil keymap nil fontified nil) s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6932 ;; Make a series of regular expressions to find a match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6933 (setq words (org-split-string s "[ \n\r\t]+")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6934
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6935 re0 (concat "\\(<<" (regexp-quote s0) ">>\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6936 re2 (concat markers "\\(" (mapconcat 'downcase words "[ \t]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6937 "\\)" markers)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6938 re2a_ (concat "\\(" (mapconcat 'downcase words "[ \t\r\n]+") "\\)[ \t\r\n]")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6939 re2a (concat "[ \t\r\n]" re2a_)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6940 re4_ (concat "\\(" (mapconcat 'downcase words "[^a-zA-Z_\r\n]+") "\\)[^a-zA-Z_]")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6941 re4 (concat "[^a-zA-Z_]" re4_)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6942
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6943 re1 (concat pre re2 post)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6944 re3 (concat pre (if pre re4_ re4) post)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6945 re5 (concat pre ".*" re4)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6946 re2 (concat pre re2)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6947 re2a (concat pre (if pre re2a_ re2a))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6948 re4 (concat pre (if pre re4_ re4))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6949 reall (concat "\\(" re0 "\\)\\|\\(" re1 "\\)\\|\\(" re2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6950 "\\)\\|\\(" re3 "\\)\\|\\(" re4 "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6951 re5 "\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6952 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6953 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6954 ((eq type 'org-occur) (org-occur reall))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6955 ((eq type 'occur) (org-do-occur (downcase reall) 'cleanup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6956 (t (goto-char (point-min))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6957 (setq type 'fuzzy)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6958 (if (or (and (org-search-not-self 1 re0 nil t) (setq type 'dedicated))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6959 (org-search-not-self 1 re1 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6960 (org-search-not-self 1 re2 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6961 (org-search-not-self 1 re2a nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6962 (org-search-not-self 1 re3 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6963 (org-search-not-self 1 re4 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6964 (org-search-not-self 1 re5 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6965 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6966 (goto-char (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6967 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6968 (error "No match")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6969 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6970 ;; Normal string-search
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6971 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6972 (if (search-forward s nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6973 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6974 (error "No match"))))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6975 (and (org-mode-p) (org-show-context 'link-search))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6976 type))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6977
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6978 (defun org-search-not-self (group &rest args)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6979 "Execute `re-search-forward', but only accept matches that do not
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6980 enclose the position of `org-open-link-marker'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6981 (let ((m org-open-link-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6982 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6983 (while (apply 're-search-forward args)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6984 (unless (get-text-property (match-end group) 'intangible) ; Emacs 21
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6985 (goto-char (match-end group))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6986 (if (and (or (not (eq (marker-buffer m) (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6987 (> (match-beginning 0) (marker-position m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6988 (< (match-end 0) (marker-position m)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6989 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6990 (or (not (org-in-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6991 org-bracket-link-analytic-regexp 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6992 (not (match-end 4)) ; no description
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6993 (and (<= (match-beginning 4) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6994 (>= (match-end 4) (point))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6995 (throw 'exit (point))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6996
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6997 (defun org-get-buffer-for-internal-link (buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6998 "Return a buffer to be used for displaying the link target of internal links."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6999 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7000 ((not org-display-internal-link-with-indirect-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7001 buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7002 ((string-match "(Clone)$" (buffer-name buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7003 (message "Buffer is already a clone, not making another one")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7004 ;; we also do not modify visibility in this case
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7005 buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7006 (t ; make a new indirect buffer for displaying the link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7007 (let* ((bn (buffer-name buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7008 (ibn (concat bn "(Clone)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7009 (ib (or (get-buffer ibn) (make-indirect-buffer buffer ibn 'clone))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7010 (with-current-buffer ib (org-overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7011 ib))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7012
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7013 (defun org-do-occur (regexp &optional cleanup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7014 "Call the Emacs command `occur'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7015 If CLEANUP is non-nil, remove the printout of the regular expression
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7016 in the *Occur* buffer. This is useful if the regex is long and not useful
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7017 to read."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7018 (occur regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7019 (when cleanup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7020 (let ((cwin (selected-window)) win beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7021 (when (setq win (get-buffer-window "*Occur*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7022 (select-window win))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7023 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7024 (when (re-search-forward "match[a-z]+" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7025 (setq beg (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7026 (if (re-search-forward "^[ \t]*[0-9]+" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7027 (setq end (1- (match-beginning 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7028 (and beg end (let ((inhibit-read-only t)) (delete-region beg end)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7029 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7030 (select-window cwin))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7031
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7032 ;;; The mark ring for links jumps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7033
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7034 (defvar org-mark-ring nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7035 "Mark ring for positions before jumps in Org-mode.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7036 (defvar org-mark-ring-last-goto nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7037 "Last position in the mark ring used to go back.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7038 ;; Fill and close the ring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7039 (setq org-mark-ring nil org-mark-ring-last-goto nil) ;; in case file is reloaded
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7040 (loop for i from 1 to org-mark-ring-length do
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7041 (push (make-marker) org-mark-ring))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7042 (setcdr (nthcdr (1- org-mark-ring-length) org-mark-ring)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7043 org-mark-ring)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7044
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7045 (defun org-mark-ring-push (&optional pos buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7046 "Put the current position or POS into the mark ring and rotate it."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7047 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7048 (setq pos (or pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7049 (setq org-mark-ring (nthcdr (1- org-mark-ring-length) org-mark-ring))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7050 (move-marker (car org-mark-ring)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7051 (or pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7052 (or buffer (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7053 (message "%s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7054 (substitute-command-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7055 "Position saved to mark ring, go back with \\[org-mark-ring-goto].")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7056
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7057 (defun org-mark-ring-goto (&optional n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7058 "Jump to the previous position in the mark ring.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7059 With prefix arg N, jump back that many stored positions. When
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7060 called several times in succession, walk through the entire ring.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7061 Org-mode commands jumping to a different position in the current file,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7062 or to another Org-mode file, automatically push the old position
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7063 onto the ring."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7064 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7065 (let (p m)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7066 (if (eq last-command this-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7067 (setq p (nthcdr n (or org-mark-ring-last-goto org-mark-ring)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7068 (setq p org-mark-ring))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7069 (setq org-mark-ring-last-goto p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7070 (setq m (car p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7071 (switch-to-buffer (marker-buffer m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7072 (goto-char m)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7073 (if (or (org-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7074
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7075 (defun org-remove-angle-brackets (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7076 (if (equal (substring s 0 1) "<") (setq s (substring s 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7077 (if (equal (substring s -1) ">") (setq s (substring s 0 -1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7078 s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7079 (defun org-add-angle-brackets (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7080 (if (equal (substring s 0 1) "<") nil (setq s (concat "<" s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7081 (if (equal (substring s -1) ">") nil (setq s (concat s ">")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7082 s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7083
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7084 ;;; Following specific links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7085
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7086 (defun org-follow-timestamp-link ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7087 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7088 ((org-at-date-range-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7089 (let ((org-agenda-start-on-weekday)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7090 (t1 (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7091 (t2 (match-string 2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7092 (setq t1 (time-to-days (org-time-string-to-time t1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7093 t2 (time-to-days (org-time-string-to-time t2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7094 (org-agenda-list nil t1 (1+ (- t2 t1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7095 ((org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7096 (org-agenda-list nil (time-to-days (org-time-string-to-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7097 (substring (match-string 1) 0 10)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7098 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7099 (t (error "This should not happen"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7100
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7101
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7102 ;;; Following file links
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7103 (defvar org-wait nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7104 (defun org-open-file (path &optional in-emacs line search)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7105 "Open the file at PATH.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7106 First, this expands any special file name abbreviations. Then the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7107 configuration variable `org-file-apps' is checked if it contains an
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7108 entry for this file type, and if yes, the corresponding command is launched.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7109 If no application is found, Emacs simply visits the file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7110 With optional argument IN-EMACS, Emacs will visit the file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7111 Optional LINE specifies a line to go to, optional SEARCH a string to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7112 search for. If LINE or SEARCH is given, the file will always be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7113 opened in Emacs.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7114 If the file does not exist, an error is thrown."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7115 (setq in-emacs (or in-emacs line search))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7116 (let* ((file (if (equal path "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7117 buffer-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7118 (substitute-in-file-name (expand-file-name path))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7119 (apps (append org-file-apps (org-default-apps)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7120 (remp (and (assq 'remote apps) (org-file-remote-p file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7121 (dirp (if remp nil (file-directory-p file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7122 (dfile (downcase file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7123 (old-buffer (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7124 (old-pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7125 (old-mode major-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7126 ext cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7127 (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\.gz\\)$" dfile)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7128 (setq ext (match-string 1 dfile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7129 (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\)$" dfile)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7130 (setq ext (match-string 1 dfile))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7131 (if in-emacs
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7132 (setq cmd 'emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7133 (setq cmd (or (and remp (cdr (assoc 'remote apps)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7134 (and dirp (cdr (assoc 'directory apps)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7135 (cdr (assoc ext apps))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7136 (cdr (assoc t apps)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7137 (when (eq cmd 'mailcap)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7138 (require 'mailcap)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7139 (mailcap-parse-mailcaps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7140 (let* ((mime-type (mailcap-extension-to-mime (or ext "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7141 (command (mailcap-mime-info mime-type)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7142 (if (stringp command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7143 (setq cmd command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7144 (setq cmd 'emacs))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7145 (if (and (not (eq cmd 'emacs)) ; Emacs has no problems with non-ex files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7146 (not (file-exists-p file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7147 (not org-open-non-existing-files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7148 (error "No such file: %s" file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7149 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7150 ((and (stringp cmd) (not (string-match "^\\s-*$" cmd)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7151 ;; Remove quotes around the file name - we'll use shell-quote-argument.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7152 (while (string-match "['\"]%s['\"]" cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7153 (setq cmd (replace-match "%s" t t cmd)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7154 (while (string-match "%s" cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7155 (setq cmd (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7156 (save-match-data (shell-quote-argument file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7157 t t cmd)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7158 (save-window-excursion
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7159 (start-process-shell-command cmd nil cmd)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7160 (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7161 ))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7162 ((or (stringp cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7163 (eq cmd 'emacs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7164 (funcall (cdr (assq 'file org-link-frame-setup)) file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7165 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7166 (if line (goto-line line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7167 (if search (org-link-search search))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7168 ((consp cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7169 (eval cmd))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7170 (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7171 (and (org-mode-p) (eq old-mode 'org-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7172 (or (not (equal old-buffer (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7173 (not (equal old-pos (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7174 (org-mark-ring-push old-pos old-buffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7175
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7176 (defun org-default-apps ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7177 "Return the default applications for this operating system."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7178 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7179 ((eq system-type 'darwin)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7180 org-file-apps-defaults-macosx)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7181 ((eq system-type 'windows-nt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7182 org-file-apps-defaults-windowsnt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7183 (t org-file-apps-defaults-gnu)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7184
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7185 (defvar ange-ftp-name-format) ; to silence the XEmacs compiler.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7186 (defun org-file-remote-p (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7187 "Test whether FILE specifies a location on a remote system.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7188 Return non-nil if the location is indeed remote.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7189
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7190 For example, the filename \"/user@host:/foo\" specifies a location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7191 on the system \"/user@host:\"."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7192 (cond ((fboundp 'file-remote-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7193 (file-remote-p file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7194 ((fboundp 'tramp-handle-file-remote-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7195 (tramp-handle-file-remote-p file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7196 ((and (boundp 'ange-ftp-name-format)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7197 (string-match (car ange-ftp-name-format) file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7198 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7199 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7200
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7201
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7202 ;;;; Refiling
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7203
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7204 (defun org-get-org-file ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7205 "Read a filename, with default directory `org-directory'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7206 (let ((default (or org-default-notes-file remember-data-file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7207 (read-file-name (format "File name [%s]: " default)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7208 (file-name-as-directory org-directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7209 default)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7210
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7211 (defun org-notes-order-reversed-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7212 "Check if the current file should receive notes in reversed order."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7213 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7214 ((not org-reverse-note-order) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7215 ((eq t org-reverse-note-order) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7216 ((not (listp org-reverse-note-order)) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7217 (t (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7218 (let ((all org-reverse-note-order)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7219 entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7220 (while (setq entry (pop all))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7221 (if (string-match (car entry) buffer-file-name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7222 (throw 'exit (cdr entry))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7223 nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7224
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7225 (defvar org-refile-target-table nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7226 "The list of refile targets, created by `org-refile'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7227
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7228 (defvar org-agenda-new-buffers nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7229 "Buffers created to visit agenda files.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7230
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7231 (defun org-get-refile-targets (&optional default-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7232 "Produce a table with refile targets."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7233 (let ((entries (or org-refile-targets '((nil . (:level . 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7234 targets txt re files f desc descre)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7235 (with-current-buffer (or default-buffer (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7236 (while (setq entry (pop entries))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7237 (setq files (car entry) desc (cdr entry))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7238 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7239 ((null files) (setq files (list (current-buffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7240 ((eq files 'org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7241 (setq files (org-agenda-files 'unrestricted)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7242 ((and (symbolp files) (fboundp files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7243 (setq files (funcall files)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7244 ((and (symbolp files) (boundp files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7245 (setq files (symbol-value files))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7246 (if (stringp files) (setq files (list files)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7247 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7248 ((eq (car desc) :tag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7249 (setq descre (concat "^\\*+[ \t]+.*?:" (regexp-quote (cdr desc)) ":")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7250 ((eq (car desc) :todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7251 (setq descre (concat "^\\*+[ \t]+" (regexp-quote (cdr desc)) "[ \t]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7252 ((eq (car desc) :regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7253 (setq descre (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7254 ((eq (car desc) :level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7255 (setq descre (concat "^\\*\\{" (number-to-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7256 (if org-odd-levels-only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7257 (1- (* 2 (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7258 (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7259 "\\}[ \t]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7260 ((eq (car desc) :maxlevel)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7261 (setq descre (concat "^\\*\\{1," (number-to-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7262 (if org-odd-levels-only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7263 (1- (* 2 (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7264 (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7265 "\\}[ \t]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7266 (t (error "Bad refiling target description %s" desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7267 (while (setq f (pop files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7268 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7269 (set-buffer (if (bufferp f) f (org-get-agenda-file-buffer f)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7270 (if (bufferp f) (setq f (buffer-file-name (buffer-base-buffer f))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7271 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7272 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7273 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7274 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7275 (while (re-search-forward descre nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7276 (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7277 (when (looking-at org-complex-heading-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7278 (setq txt (match-string 4)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7279 re (concat "^" (regexp-quote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7280 (buffer-substring (match-beginning 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7281 (match-end 4)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7282 (if (match-end 5) (setq re (concat re "[ \t]+"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7283 (regexp-quote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7284 (match-string 5)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7285 (setq re (concat re "[ \t]*$"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7286 (when org-refile-use-outline-path
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7287 (setq txt (mapconcat 'identity
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7288 (append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7289 (if (eq org-refile-use-outline-path 'file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7290 (list (file-name-nondirectory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7291 (buffer-file-name (buffer-base-buffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7292 (if (eq org-refile-use-outline-path 'full-file-path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7293 (list (buffer-file-name (buffer-base-buffer)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7294 (org-get-outline-path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7295 (list txt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7296 "/")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7297 (push (list txt f re (point)) targets))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7298 (goto-char (point-at-eol))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7299 (nreverse targets))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7300
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7301 (defun org-get-outline-path ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7302 "Return the outline path to the current entry, as a list."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7303 (let (rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7304 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7305 (while (org-up-heading-safe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7306 (when (looking-at org-complex-heading-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7307 (push (org-match-string-no-properties 4) rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7308 rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7309
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7310 (defvar org-refile-history nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7311 "History for refiling operations.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7312
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7313 (defun org-refile (&optional goto default-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7314 "Move the entry at point to another heading.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7315 The list of target headings is compiled using the information in
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7316 `org-refile-targets', which see. This list is created before each use
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7317 and will therefore always be up-to-date.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7318
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7319 At the target location, the entry is filed as a subitem of the target heading.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7320 Depending on `org-reverse-note-order', the new subitem will either be the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7321 first of the last subitem.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7322
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7323 With prefix arg GOTO, the command will only visit the target location,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7324 not actually move anything.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7325 With a double prefix `C-c C-c', go to the location where the last refiling
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7326 operation has put the subtree."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7327 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7328 (let* ((cbuf (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7329 (filename (buffer-file-name (buffer-base-buffer cbuf)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7330 pos it nbuf file re level reversed)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7331 (if (equal goto '(16))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7332 (org-refile-goto-last-stored)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7333 (when (setq it (org-refile-get-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7334 (if goto "Goto: " "Refile to: ") default-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7335 (setq file (nth 1 it)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7336 re (nth 2 it)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7337 pos (nth 3 it))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7338 (setq nbuf (or (find-buffer-visiting file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7339 (find-file-noselect file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7340 (if goto
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7341 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7342 (switch-to-buffer nbuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7343 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7344 (org-show-context 'org-goto))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7345 (org-copy-special)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7346 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7347 (set-buffer (setq nbuf (or (find-buffer-visiting file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7348 (find-file-noselect file))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7349 (setq reversed (org-notes-order-reversed-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7350 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7351 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7352 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7353 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7354 (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7355 (setq level (org-get-valid-level (funcall outline-level) 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7356 (goto-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7357 (if reversed
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7358 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7359 (or (save-excursion (outline-get-next-sibling))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7360 (org-end-of-subtree t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7361 (point-max))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7362 (bookmark-set "org-refile-last-stored")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7363 (org-paste-subtree level))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7364 (org-cut-special)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7365 (message "Entry refiled to \"%s\"" (car it)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7366
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7367 (defun org-refile-goto-last-stored ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7368 "Go to the location where the last refile was stored."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7369 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7370 (bookmark-jump "org-refile-last-stored")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7371 (message "This is the location of the last refile"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7372
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7373 (defun org-refile-get-location (&optional prompt default-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7374 "Prompt the user for a refile location, using PROMPT."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7375 (let ((org-refile-targets org-refile-targets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7376 (org-refile-use-outline-path org-refile-use-outline-path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7377 (setq org-refile-target-table (org-get-refile-targets default-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7378 (unless org-refile-target-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7379 (error "No refile targets"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7380 (let* ((cbuf (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7381 (filename (buffer-file-name (buffer-base-buffer cbuf)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7382 (fname (and filename (file-truename filename)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7383 (tbl (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7384 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7385 (if (not (equal fname (file-truename (nth 1 x))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7386 (cons (concat (car x) " (" (file-name-nondirectory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7387 (nth 1 x)) ")")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7388 (cdr x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7389 x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7390 org-refile-target-table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7391 (completion-ignore-case t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7392 (assoc (completing-read prompt tbl nil t nil 'org-refile-history)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7393 tbl)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7394
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7395 ;;;; Dynamic blocks
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7396
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7397 (defun org-find-dblock (name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7398 "Find the first dynamic block with name NAME in the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7399 If not found, stay at current position and return nil."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7400 (let (pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7401 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7402 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7403 (setq pos (and (re-search-forward (concat "^#\\+BEGIN:[ \t]+" name "\\>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7404 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7405 (match-beginning 0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7406 (if pos (goto-char pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7407 pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7408
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7409 (defconst org-dblock-start-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7410 "^#\\+BEGIN:[ \t]+\\(\\S-+\\)\\([ \t]+\\(.*\\)\\)?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7411 "Matches the startline of a dynamic block, with parameters.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7412
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7413 (defconst org-dblock-end-re "^#\\+END\\([: \t\r\n]\\|$\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7414 "Matches the end of a dyhamic block.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7415
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7416 (defun org-create-dblock (plist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7417 "Create a dynamic block section, with parameters taken from PLIST.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7418 PLIST must containe a :name entry which is used as name of the block."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7419 (unless (bolp) (newline))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7420 (let ((name (plist-get plist :name)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7421 (insert "#+BEGIN: " name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7422 (while plist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7423 (if (eq (car plist) :name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7424 (setq plist (cddr plist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7425 (insert " " (prin1-to-string (pop plist)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7426 (insert "\n\n#+END:\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7427 (beginning-of-line -2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7428
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7429 (defun org-prepare-dblock ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7430 "Prepare dynamic block for refresh.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7431 This empties the block, puts the cursor at the insert position and returns
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7432 the property list including an extra property :name with the block name."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7433 (unless (looking-at org-dblock-start-re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7434 (error "Not at a dynamic block"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7435 (let* ((begdel (1+ (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7436 (name (org-no-properties (match-string 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7437 (params (append (list :name name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7438 (read (concat "(" (match-string 3) ")")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7439 (unless (re-search-forward org-dblock-end-re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7440 (error "Dynamic block not terminated"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7441 (setq params
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7442 (append params
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7443 (list :content (buffer-substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7444 begdel (match-beginning 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7445 (delete-region begdel (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7446 (goto-char begdel)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7447 (open-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7448 params))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7449
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7450 (defun org-map-dblocks (&optional command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7451 "Apply COMMAND to all dynamic blocks in the current buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7452 If COMMAND is not given, use `org-update-dblock'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7453 (let ((cmd (or command 'org-update-dblock))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7454 pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7455 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7456 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7457 (while (re-search-forward org-dblock-start-re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7458 (goto-char (setq pos (match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7459 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7460 (funcall cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7461 (error (message "Error during update of dynamic block")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7462 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7463 (unless (re-search-forward org-dblock-end-re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7464 (error "Dynamic block not terminated"))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7465
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7466 (defun org-dblock-update (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7467 "User command for updating dynamic blocks.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7468 Update the dynamic block at point. With prefix ARG, update all dynamic
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7469 blocks in the buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7470 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7471 (if arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7472 (org-update-all-dblocks)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7473 (or (looking-at org-dblock-start-re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7474 (org-beginning-of-dblock))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7475 (org-update-dblock)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7476
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7477 (defun org-update-dblock ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7478 "Update the dynamic block at point
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7479 This means to empty the block, parse for parameters and then call
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7480 the correct writing function."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7481 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7482 (let* ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7483 (line (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7484 (params (org-prepare-dblock))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7485 (name (plist-get params :name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7486 (cmd (intern (concat "org-dblock-write:" name))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7487 (message "Updating dynamic block `%s' at line %d..." name line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7488 (funcall cmd params)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7489 (message "Updating dynamic block `%s' at line %d...done" name line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7490 (goto-char pos))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7491
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7492 (defun org-beginning-of-dblock ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7493 "Find the beginning of the dynamic block at point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7494 Error if there is no scuh block at point."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7495 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7496 beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7497 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7498 (if (and (re-search-backward org-dblock-start-re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7499 (setq beg (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7500 (re-search-forward org-dblock-end-re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7501 (> (match-end 0) pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7502 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7503 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7504 (error "Not in a dynamic block"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7505
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7506 (defun org-update-all-dblocks ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7507 "Update all dynamic blocks in the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7508 This function can be used in a hook."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7509 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7510 (org-map-dblocks 'org-update-dblock)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7511
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7512
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7513 ;;;; Completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7514
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7515 (defconst org-additional-option-like-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7516 '("BEGIN_HTML" "BEGIN_LaTeX" "END_HTML" "END_LaTeX"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7517 "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "TBLFM"
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7518 "BEGIN_EXAMPLE" "END_EXAMPLE"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7519
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7520 (defun org-complete (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7521 "Perform completion on word at point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7522 At the beginning of a headline, this completes TODO keywords as given in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7523 `org-todo-keywords'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7524 If the current word is preceded by a backslash, completes the TeX symbols
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7525 that are supported for HTML support.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7526 If the current word is preceded by \"#+\", completes special words for
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7527 setting file options.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7528 In the line after \"#+STARTUP:, complete valid keywords.\"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7529 At all other locations, this simply calls the value of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7530 `org-completion-fallback-command'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7531 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7532 (org-without-partial-completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7533 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7534 (let* ((end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7535 (beg1 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7536 (skip-chars-backward (org-re "[:alnum:]_@"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7537 (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7538 (beg (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7539 (skip-chars-backward "a-zA-Z0-9_:$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7540 (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7541 (confirm (lambda (x) (stringp (car x))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7542 (searchhead (equal (char-before beg) ?*))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7543 (tag (and (equal (char-before beg1) ?:)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7544 (equal (char-after (point-at-bol)) ?*)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7545 (prop (and (equal (char-before beg1) ?:)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7546 (not (equal (char-after (point-at-bol)) ?*))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7547 (texp (equal (char-before beg) ?\\))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7548 (link (equal (char-before beg) ?\[))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7549 (opt (equal (buffer-substring (max (point-at-bol) (- beg 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7550 beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7551 "#+"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7552 (startup (string-match "^#\\+STARTUP:.*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7553 (buffer-substring (point-at-bol) (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7554 (completion-ignore-case opt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7555 (type nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7556 (tbl nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7557 (table (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7558 (opt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7559 (setq type :opt)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7560 (require 'org-exp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7561 (append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7562 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7563 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7564 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7565 (cons (match-string 2 x) (match-string 1 x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7566 (org-split-string (org-get-current-options) "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7567 (mapcar 'list org-additional-option-like-keywords)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7568 (startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7569 (setq type :startup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7570 org-startup-options)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7571 (link (append org-link-abbrev-alist-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7572 org-link-abbrev-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7573 (texp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7574 (setq type :tex)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7575 org-html-entities)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7576 ((string-match "\\`\\*+[ \t]+\\'"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7577 (buffer-substring (point-at-bol) beg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7578 (setq type :todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7579 (mapcar 'list org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7580 (searchhead
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7581 (setq type :searchhead)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7582 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7583 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7584 (while (re-search-forward org-todo-line-regexp nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7585 (push (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7586 (org-make-org-heading-search-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7587 (match-string 3) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7588 tbl)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7589 tbl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7590 (tag (setq type :tag beg beg1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7591 (or org-tag-alist (org-get-buffer-tags)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7592 (prop (setq type :prop beg beg1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7593 (mapcar 'list (org-buffer-property-keys nil t t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7594 (t (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7595 (call-interactively org-completion-fallback-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7596 (throw 'exit nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7597 (pattern (buffer-substring-no-properties beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7598 (completion (try-completion pattern table confirm)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7599 (cond ((eq completion t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7600 (if (not (assoc (upcase pattern) table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7601 (message "Already complete")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7602 (if (and (equal type :opt)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7603 (not (member (car (assoc (upcase pattern) table))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7604 org-additional-option-like-keywords)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7605 (insert (substring (cdr (assoc (upcase pattern) table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7606 (length pattern)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7607 (if (memq type '(:tag :prop)) (insert ":")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7608 ((null completion)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7609 (message "Can't find completion for \"%s\"" pattern)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7610 (ding))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7611 ((not (string= pattern completion))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7612 (delete-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7613 (if (string-match " +$" completion)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7614 (setq completion (replace-match "" t t completion)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7615 (insert completion)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7616 (if (get-buffer-window "*Completions*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7617 (delete-window (get-buffer-window "*Completions*")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7618 (if (assoc completion table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7619 (if (eq type :todo) (insert " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7620 (if (memq type '(:tag :prop)) (insert ":"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7621 (if (and (equal type :opt) (assoc completion table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7622 (message "%s" (substitute-command-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7623 "Press \\[org-complete] again to insert example settings"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7624 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7625 (message "Making completion list...")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7626 (let ((list (sort (all-completions pattern table confirm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7627 'string<)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7628 (with-output-to-temp-buffer "*Completions*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7629 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7630 ;; Protection needed for XEmacs and emacs 21
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7631 (display-completion-list list pattern)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7632 (error (display-completion-list list)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7633 (message "Making completion list...%s" "done")))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7634
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7635 ;;;; TODO, DEADLINE, Comments
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7636
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7637 (defun org-toggle-comment ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7638 "Change the COMMENT state of an entry."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7639 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7640 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7641 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7642 (let (case-fold-search)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7643 (if (looking-at (concat outline-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7644 "\\( *\\<" org-comment-string "\\>[ \t]*\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7645 (replace-match "" t t nil 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7646 (if (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7647 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7648 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7649 (insert org-comment-string " ")))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7650
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7651 (defvar org-last-todo-state-is-todo nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7652 "This is non-nil when the last TODO state change led to a TODO state.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7653 If the last change removed the TODO tag or switched to DONE, then
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7654 this is nil.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7655
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7656 (defvar org-setting-tags nil) ; dynamically skiped
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7657
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7658 (defun org-parse-local-options (string var)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7659 "Parse STRING for startup setting relevant for variable VAR."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7660 (let ((rtn (symbol-value var))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7661 e opts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7662 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7663 (if (or (not string) (not (string-match "\\S-" string)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7664 rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7665 (setq opts (delq nil (mapcar (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7666 (setq e (assoc x org-startup-options))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7667 (if (eq (nth 1 e) var) e nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7668 (org-split-string string "[ \t]+"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7669 (if (not opts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7670 rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7671 (setq rtn nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7672 (while (setq e (pop opts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7673 (if (not (nth 3 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7674 (setq rtn (nth 2 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7675 (if (not (listp rtn)) (setq rtn nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7676 (push (nth 2 e) rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7677 rtn)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7678
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7679 (defvar org-blocker-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7680 "Hook for functions that are allowed to block a state change.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7681
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7682 Each function gets as its single argument a property list, see
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7683 `org-trigger-hook' for more information about this list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7684
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7685 If any of the functions in this hook returns nil, the state change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7686 is blocked.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7687
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7688 (defvar org-trigger-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7689 "Hook for functions that are triggered by a state change.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7690
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7691 Each function gets as its single argument a property list with at least
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7692 the following elements:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7693
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7694 (:type type-of-change :position pos-at-entry-start
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7695 :from old-state :to new-state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7696
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7697 Depending on the type, more properties may be present.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7698
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7699 This mechanism is currently implemented for:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7700
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7701 TODO state changes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7702 ------------------
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7703 :type todo-state-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7704 :from previous state (keyword as a string), or nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7705 :to new state (keyword as a string), or nil")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7706
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7707
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7708 (defun org-todo (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7709 "Change the TODO state of an item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7710 The state of an item is given by a keyword at the start of the heading,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7711 like
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7712 *** TODO Write paper
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7713 *** DONE Call mom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7714
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7715 The different keywords are specified in the variable `org-todo-keywords'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7716 By default the available states are \"TODO\" and \"DONE\".
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7717 So for this example: when the item starts with TODO, it is changed to DONE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7718 When it starts with DONE, the DONE is removed. And when neither TODO nor
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7719 DONE are present, add TODO at the beginning of the heading.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7720
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7721 With C-u prefix arg, use completion to determine the new state.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7722 With numeric prefix arg, switch to that state.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7723
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7724 For calling through lisp, arg is also interpreted in the following way:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7725 'none -> empty state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7726 \"\"(empty string) -> switch to empty state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7727 'done -> switch to DONE
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7728 'nextset -> switch to the next set of keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7729 'previousset -> switch to the previous set of keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7730 \"WAITING\" -> switch to the specified keyword, but only if it
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7731 really is a member of `org-todo-keywords'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7732 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7733 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7734 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7735 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7736 (if (looking-at outline-regexp) (goto-char (1- (match-end 0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7737 (or (looking-at (concat " +" org-todo-regexp " *"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7738 (looking-at " *"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7739 (let* ((match-data (match-data))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7740 (startpos (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7741 (logging (save-match-data (org-entry-get nil "LOGGING" t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7742 (org-log-done org-log-done)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7743 (org-log-repeat org-log-repeat)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7744 (org-todo-log-states org-todo-log-states)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7745 (this (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7746 (hl-pos (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7747 (head (org-get-todo-sequence-head this))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7748 (ass (assoc head org-todo-kwd-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7749 (interpret (nth 1 ass))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7750 (done-word (nth 3 ass))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7751 (final-done-word (nth 4 ass))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7752 (last-state (or this ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7753 (completion-ignore-case t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7754 (member (member this org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7755 (tail (cdr member))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7756 (state (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7757 ((and org-todo-key-trigger
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7758 (or (and (equal arg '(4)) (eq org-use-fast-todo-selection 'prefix))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7759 (and (not arg) org-use-fast-todo-selection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7760 (not (eq org-use-fast-todo-selection 'prefix)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7761 ;; Use fast selection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7762 (org-fast-todo-selection))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7763 ((and (equal arg '(4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7764 (or (not org-use-fast-todo-selection)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7765 (not org-todo-key-trigger)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7766 ;; Read a state with completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7767 (completing-read "State: " (mapcar (lambda(x) (list x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7768 org-todo-keywords-1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7769 nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7770 ((eq arg 'right)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7771 (if this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7772 (if tail (car tail) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7773 (car org-todo-keywords-1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7774 ((eq arg 'left)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7775 (if (equal member org-todo-keywords-1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7776 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7777 (if this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7778 (nth (- (length org-todo-keywords-1) (length tail) 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7779 org-todo-keywords-1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7780 (org-last org-todo-keywords-1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7781 ((and (eq org-use-fast-todo-selection t) (equal arg '(4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7782 (setq arg nil))) ; hack to fall back to cycling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7783 (arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7784 ;; user or caller requests a specific state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7785 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7786 ((equal arg "") nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7787 ((eq arg 'none) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7788 ((eq arg 'done) (or done-word (car org-done-keywords)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7789 ((eq arg 'nextset)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7790 (or (car (cdr (member head org-todo-heads)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7791 (car org-todo-heads)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7792 ((eq arg 'previousset)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7793 (let ((org-todo-heads (reverse org-todo-heads)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7794 (or (car (cdr (member head org-todo-heads)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7795 (car org-todo-heads))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7796 ((car (member arg org-todo-keywords-1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7797 ((nth (1- (prefix-numeric-value arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7798 org-todo-keywords-1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7799 ((null member) (or head (car org-todo-keywords-1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7800 ((equal this final-done-word) nil) ;; -> make empty
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7801 ((null tail) nil) ;; -> first entry
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7802 ((eq interpret 'sequence)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7803 (car tail))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7804 ((memq interpret '(type priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7805 (if (eq this-command last-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7806 (car tail)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7807 (if (> (length tail) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7808 (or done-word (car org-done-keywords))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7809 nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7810 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7811 (next (if state (concat " " state " ") " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7812 (change-plist (list :type 'todo-state-change :from this :to state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7813 :position startpos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7814 dolog now-done-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7815 (when org-blocker-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7816 (unless (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7817 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7818 (run-hook-with-args-until-failure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7819 'org-blocker-hook change-plist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7820 (if (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7821 (error "TODO state change from %s to %s blocked" this state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7822 ;; fail silently
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7823 (message "TODO state change from %s to %s blocked" this state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7824 (throw 'exit nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7825 (store-match-data match-data)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7826 (replace-match next t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7827 (unless (pos-visible-in-window-p hl-pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7828 (message "TODO state changed to %s" (org-trim next)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7829 (unless head
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7830 (setq head (org-get-todo-sequence-head state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7831 ass (assoc head org-todo-kwd-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7832 interpret (nth 1 ass)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7833 done-word (nth 3 ass)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7834 final-done-word (nth 4 ass)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7835 (when (memq arg '(nextset previousset))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7836 (message "Keyword-Set %d/%d: %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7837 (- (length org-todo-sets) -1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7838 (length (memq (assoc state org-todo-sets) org-todo-sets)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7839 (length org-todo-sets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7840 (mapconcat 'identity (assoc state org-todo-sets) " ")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7841 (setq org-last-todo-state-is-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7842 (not (member state org-done-keywords)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7843 (setq now-done-p (and (member state org-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7844 (not (member this org-done-keywords))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7845 (and logging (org-local-logging logging))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7846 (when (and (or org-todo-log-states org-log-done)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7847 (not (memq arg '(nextset previousset))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7848 ;; we need to look at recording a time and note
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7849 (setq dolog (or (nth 1 (assoc state org-todo-log-states))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7850 (nth 2 (assoc this org-todo-log-states))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7851 (when (and state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7852 (member state org-not-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7853 (not (member this org-not-done-keywords)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7854 ;; This is now a todo state and was not one before
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7855 ;; If there was a CLOSED time stamp, get rid of it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7856 (org-add-planning-info nil nil 'closed))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7857 (when (and now-done-p org-log-done)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7858 ;; It is now done, and it was not done before
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7859 (org-add-planning-info 'closed (org-current-time))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7860 (if (and (not dolog) (eq 'note org-log-done))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7861 (org-add-log-setup 'done state 'findpos 'note)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7862 (when (and state dolog)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7863 ;; This is a non-nil state, and we need to log it
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7864 (org-add-log-setup 'state state 'findpos dolog)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7865 ;; Fixup tag positioning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7866 (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7867 (run-hooks 'org-after-todo-state-change-hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7868 (if (and arg (not (member state org-done-keywords)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7869 (setq head (org-get-todo-sequence-head state)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7870 (put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7871 ;; Do we need to trigger a repeat?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7872 (when now-done-p (org-auto-repeat-maybe state))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7873 ;; Fixup cursor location if close to the keyword
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7874 (if (and (outline-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7875 (not (bolp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7876 (save-excursion (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7877 (looking-at org-todo-line-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7878 (< (point) (+ 2 (or (match-end 2) (match-end 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7879 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7880 (goto-char (or (match-end 2) (match-end 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7881 (just-one-space)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7882 (when org-trigger-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7883 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7884 (run-hook-with-args 'org-trigger-hook change-plist)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7885
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7886 (defun org-local-logging (value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7887 "Get logging settings from a property VALUE."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7888 (let* (words w a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7889 ;; directly set the variables, they are already local.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7890 (setq org-log-done nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7891 org-log-repeat nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7892 org-todo-log-states nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7893 (setq words (org-split-string value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7894 (while (setq w (pop words))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7895 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7896 ((setq a (assoc w org-startup-options))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7897 (and (member (nth 1 a) '(org-log-done org-log-repeat))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7898 (set (nth 1 a) (nth 2 a))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7899 ((setq a (org-extract-log-state-settings w))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7900 (and (member (car a) org-todo-keywords-1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7901 (push a org-todo-log-states)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7902
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7903 (defun org-get-todo-sequence-head (kwd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7904 "Return the head of the TODO sequence to which KWD belongs.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7905 If KWD is not set, check if there is a text property remembering the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7906 right sequence."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7907 (let (p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7908 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7909 ((not kwd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7910 (or (get-text-property (point-at-bol) 'org-todo-head)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7911 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7912 (setq p (next-single-property-change (point-at-bol) 'org-todo-head
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7913 nil (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7914 (get-text-property p 'org-todo-head))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7915 ((not (member kwd org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7916 (car org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7917 (t (nth 2 (assoc kwd org-todo-kwd-alist))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7918
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7919 (defun org-fast-todo-selection ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7920 "Fast TODO keyword selection with single keys.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7921 Returns the new TODO keyword, or nil if no state change should occur."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7922 (let* ((fulltable org-todo-key-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7923 (done-keywords org-done-keywords) ;; needed for the faces.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7924 (maxlen (apply 'max (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7925 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7926 (if (stringp (car x)) (string-width (car x)) 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7927 fulltable)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7928 (expert nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7929 (fwidth (+ maxlen 3 1 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7930 (ncol (/ (- (window-width) 4) fwidth))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7931 tg cnt e c tbl
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7932 groups ingroup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7933 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7934 (if expert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7935 (set-buffer (get-buffer-create " *Org todo*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7936 (org-switch-to-buffer-other-window (get-buffer-create " *Org todo*")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7937 (erase-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7938 (org-set-local 'org-done-keywords done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7939 (setq tbl fulltable cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7940 (while (setq e (pop tbl))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7941 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7942 ((equal e '(:startgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7943 (push '() groups) (setq ingroup t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7944 (when (not (= cnt 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7945 (setq cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7946 (insert "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7947 (insert "{ "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7948 ((equal e '(:endgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7949 (setq ingroup nil cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7950 (insert "}\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7951 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7952 (setq tg (car e) c (cdr e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7953 (if ingroup (push tg (car groups)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7954 (setq tg (org-add-props tg nil 'face
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7955 (org-get-todo-face tg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7956 (if (and (= cnt 0) (not ingroup)) (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7957 (insert "[" c "] " tg (make-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7958 (- fwidth 4 (length tg)) ?\ ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7959 (when (= (setq cnt (1+ cnt)) ncol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7960 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7961 (if ingroup (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7962 (setq cnt 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7963 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7964 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7965 (if (and (not expert) (fboundp 'fit-window-to-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7966 (fit-window-to-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7967 (message "[a-z..]:Set [SPC]:clear")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7968 (setq c (let ((inhibit-quit t)) (read-char-exclusive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7969 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7970 ((or (= c ?\C-g)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7971 (and (= c ?q) (not (rassoc c fulltable))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7972 (setq quit-flag t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7973 ((= c ?\ ) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7974 ((setq e (rassoc c fulltable) tg (car e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7975 tg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7976 (t (setq quit-flag t))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7977
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7978 (defun org-entry-is-todo-p ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7979 (member (org-get-todo-state) org-not-done-keywords))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7980
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7981 (defun org-entry-is-done-p ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7982 (member (org-get-todo-state) org-done-keywords))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7983
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7984 (defun org-get-todo-state ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7985 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7986 (org-back-to-heading t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7987 (and (looking-at org-todo-line-regexp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7988 (match-end 2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7989 (match-string 2))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7990
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7991 (defun org-at-date-range-p (&optional inactive-ok)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7992 "Is the cursor inside a date range?"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7993 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7994 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7995 (catch 'exit
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7996 (let ((pos (point)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7997 (skip-chars-backward "^[<\r\n")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7998 (skip-chars-backward "<[")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7999 (and (looking-at (if inactive-ok org-tr-regexp-both org-tr-regexp))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8000 (>= (match-end 0) pos)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8001 (throw 'exit t))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8002 (skip-chars-backward "^<[\r\n")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8003 (skip-chars-backward "<[")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8004 (and (looking-at (if inactive-ok org-tr-regexp-both org-tr-regexp))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8005 (>= (match-end 0) pos)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8006 (throw 'exit t)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8007 nil)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8008
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8009 (defun org-get-repeat ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8010 "Check if tere is a deadline/schedule with repeater in this entry."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8011 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8012 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8013 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8014 (if (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8015 org-repeat-re (save-excursion (outline-next-heading) (point)) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8016 (match-string 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8017
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8018 (defvar org-last-changed-timestamp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8019 (defvar org-log-post-message)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8020 (defvar org-log-note-purpose)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8021 (defvar org-log-note-how)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8022 (defun org-auto-repeat-maybe (done-word)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8023 "Check if the current headline contains a repeated deadline/schedule.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8024 If yes, set TODO state back to what it was and change the base date
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8025 of repeating deadline/scheduled time stamps to new date.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8026 This function is run automatically after each state change to a DONE state."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8027 ;; last-state is dynamically scoped into this function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8028 (let* ((repeat (org-get-repeat))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8029 (aa (assoc last-state org-todo-kwd-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8030 (interpret (nth 1 aa))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8031 (head (nth 2 aa))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8032 (whata '(("d" . day) ("m" . month) ("y" . year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8033 (msg "Entry repeats: ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8034 (org-log-done nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8035 (org-todo-log-states nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8036 (nshiftmax 10) (nshift 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8037 re type n what ts mb0 time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8038 (when repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8039 (if (eq org-log-repeat t) (setq org-log-repeat 'state))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8040 (org-todo (if (eq interpret 'type) last-state head))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8041 (when org-log-repeat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8042 (if (or (memq 'org-add-log-note (default-value 'post-command-hook))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8043 (memq 'org-add-log-note post-command-hook))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8044 ;; OK, we are already setup for some record
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8045 (if (eq org-log-repeat 'note)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8046 ;; make sure we take a note, not only a time stamp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8047 (setq org-log-note-how 'note))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8048 ;; Set up for taking a record
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8049 (org-add-log-setup 'state (or done-word (car org-done-keywords))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8050 'findpos org-log-repeat)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8051 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8052 (org-add-planning-info nil nil 'closed)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8053 (setq re (concat "\\(" org-scheduled-time-regexp "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8054 org-deadline-time-regexp "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8055 org-ts-regexp "\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8056 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8057 re (save-excursion (outline-next-heading) (point)) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8058 (setq type (if (match-end 1) org-scheduled-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8059 (if (match-end 3) org-deadline-string "Plain:"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8060 ts (match-string (if (match-end 2) 2 (if (match-end 4) 4 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8061 mb0 (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8062 (when (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8063 (setq n (string-to-number (match-string 2 ts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8064 what (match-string 3 ts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8065 (if (equal what "w") (setq n (* n 7) what "d"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8066 ;; Preparation, see if we need to modify the start date for the change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8067 (when (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8068 (setq time (save-match-data (org-time-string-to-time ts)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8069 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8070 ((equal (match-string 1 ts) ".")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8071 ;; Shift starting date to today
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8072 (org-timestamp-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8073 (- (time-to-days (current-time)) (time-to-days time))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8074 'day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8075 ((equal (match-string 1 ts) "+")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8076 (while (or (= nshift 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8077 (<= (time-to-days time) (time-to-days (current-time))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8078 (when (= (incf nshift) nshiftmax)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8079 (or (y-or-n-p (message "%d repeater intervals were not enough to shift date past today. Continue? " nshift))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8080 (error "Abort")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8081 (org-timestamp-change n (cdr (assoc what whata)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8082 (org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8083 (setq ts (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8084 (setq time (save-match-data (org-time-string-to-time ts))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8085 (org-timestamp-change (- n) (cdr (assoc what whata)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8086 ;; rematch, so that we have everything in place for the real shift
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8087 (org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8088 (setq ts (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8089 (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8090 (org-timestamp-change n (cdr (assoc what whata)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8091 (setq msg (concat msg type org-last-changed-timestamp " "))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8092 (setq org-log-post-message msg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8093 (message "%s" msg))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8094
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8095 (defun org-show-todo-tree (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8096 "Make a compact tree which shows all headlines marked with TODO.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8097 The tree will show the lines where the regexp matches, and all higher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8098 headlines above the match.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8099 With a \\[universal-argument] prefix, also show the DONE entries.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8100 With a numeric prefix N, construct a sparse tree for the Nth element
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8101 of `org-todo-keywords-1'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8102 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8103 (let ((case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8104 (kwd-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8105 (cond ((null arg) org-not-done-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8106 ((equal arg '(4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8107 (let ((kwd (completing-read "Keyword (or KWD1|KWD2|...): "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8108 (mapcar 'list org-todo-keywords-1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8109 (concat "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8110 (mapconcat 'identity (org-split-string kwd "|") "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8111 "\\)\\>")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8112 ((<= (prefix-numeric-value arg) (length org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8113 (regexp-quote (nth (1- (prefix-numeric-value arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8114 org-todo-keywords-1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8115 (t (error "Invalid prefix argument: %s" arg)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8116 (message "%d TODO entries found"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8117 (org-occur (concat "^" outline-regexp " *" kwd-re )))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8118
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8119 (defun org-deadline (&optional remove)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8120 "Insert the \"DEADLINE:\" string with a timestamp to make a deadline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8121 With argument REMOVE, remove any deadline from the item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8122 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8123 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8124 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8125 (org-remove-timestamp-with-keyword org-deadline-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8126 (message "Item no longer has a deadline."))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8127 (org-add-planning-info 'deadline nil 'closed)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8128
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8129 (defun org-schedule (&optional remove)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8130 "Insert the SCHEDULED: string with a timestamp to schedule a TODO item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8131 With argument REMOVE, remove any scheduling date from the item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8132 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8133 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8134 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8135 (org-remove-timestamp-with-keyword org-scheduled-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8136 (message "Item is no longer scheduled."))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8137 (org-add-planning-info 'scheduled nil 'closed)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8138
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8139 (defun org-remove-timestamp-with-keyword (keyword)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8140 "Remove all time stamps with KEYWORD in the current entry."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8141 (let ((re (concat "\\<" (regexp-quote keyword) " +<[^>\n]+>[ \t]*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8142 beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8143 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8144 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8145 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8146 (org-end-of-subtree t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8147 (while (re-search-backward re beg t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8148 (replace-match "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8149 (unless (string-match "\\S-" (buffer-substring (point-at-bol) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8150 (delete-region (point-at-bol) (min (1+ (point)) (point-max))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8151
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8152 (defun org-add-planning-info (what &optional time &rest remove)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8153 "Insert new timestamp with keyword in the line directly after the headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8154 WHAT indicates what kind of time stamp to add. TIME indicated the time to use.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8155 If non is given, the user is prompted for a date.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8156 REMOVE indicates what kind of entries to remove. An old WHAT entry will also
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8157 be removed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8158 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8159 (let (org-time-was-given org-end-time-was-given ts
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8160 end default-time default-input)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8161
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8162 (when (and (not time) (memq what '(scheduled deadline)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8163 ;; Try to get a default date/time from existing timestamp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8164 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8165 (org-back-to-heading t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8166 (setq end (save-excursion (outline-next-heading) (point)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8167 (when (re-search-forward (if (eq what 'scheduled)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8168 org-scheduled-time-regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8169 org-deadline-time-regexp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8170 end t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8171 (setq ts (match-string 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8172 default-time
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8173 (apply 'encode-time (org-parse-time-string ts))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8174 default-input (and ts (org-get-compact-tod ts))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8175 (when what
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8176 ;; If necessary, get the time from the user
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8177 (setq time (or time (org-read-date nil 'to-time nil nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8178 default-time default-input))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8179
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8180 (when (and org-insert-labeled-timestamps-at-point
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8181 (member what '(scheduled deadline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8182 (insert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8183 (if (eq what 'scheduled) org-scheduled-string org-deadline-string) " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8184 (org-insert-time-stamp time org-time-was-given
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8185 nil nil nil (list org-end-time-was-given))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8186 (setq what nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8187 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8188 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8189 (let (col list elt ts buffer-invisibility-spec)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8190 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8191 (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8192 (goto-char (match-end 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8193 (setq col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8194 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8195 (if (eobp) (insert "\n") (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8196 (if (and (not (looking-at outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8197 (looking-at (concat "[^\r\n]*?" org-keyword-time-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8198 "[^\r\n]*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8199 (not (equal (match-string 1) org-clock-string)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8200 (narrow-to-region (match-beginning 0) (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8201 (insert-before-markers "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8202 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8203 (narrow-to-region (point) (point))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8204 (org-indent-to-column col))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8205 ;; Check if we have to remove something.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8206 (setq list (cons what remove))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8207 (while list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8208 (setq elt (pop list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8209 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8210 (when (or (and (eq elt 'scheduled)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8211 (re-search-forward org-scheduled-time-regexp nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8212 (and (eq elt 'deadline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8213 (re-search-forward org-deadline-time-regexp nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8214 (and (eq elt 'closed)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8215 (re-search-forward org-closed-time-regexp nil t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8216 (replace-match "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8217 (if (looking-at "--+<[^>]+>") (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8218 (if (looking-at " +") (replace-match ""))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8219 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8220 (when what
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8221 (insert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8222 (if (not (equal (char-before) ?\ )) " " "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8223 (cond ((eq what 'scheduled) org-scheduled-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8224 ((eq what 'deadline) org-deadline-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8225 ((eq what 'closed) org-closed-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8226 " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8227 (setq ts (org-insert-time-stamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8228 time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8229 (or org-time-was-given
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8230 (and (eq what 'closed) org-log-done-with-time))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8231 (eq what 'closed)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8232 nil nil (list org-end-time-was-given)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8233 (end-of-line 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8234 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8235 (widen)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8236 (if (and (looking-at "[ \t]+\n")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8237 (equal (char-before) ?\n))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8238 (backward-delete-char 1))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8239 ts)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8240
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8241 (defvar org-log-note-marker (make-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8242 (defvar org-log-note-purpose nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8243 (defvar org-log-note-state nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8244 (defvar org-log-note-how nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8245 (defvar org-log-note-window-configuration nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8246 (defvar org-log-note-return-to (make-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8247 (defvar org-log-post-message nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8248 "Message to be displayed after a log note has been stored.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8249 The auto-repeater uses this.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8250
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8251 (defun org-add-note ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8252 "Add a note to the current entry.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8253 This is done in the same way as adding a state change note."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8254 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8255 (org-add-log-setup 'note nil t nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8256
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8257 (defun org-add-log-setup (&optional purpose state findpos how)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8258 "Set up the post command hook to take a note.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8259 If this is about to TODO state change, the new state is expected in STATE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8260 When FINDPOS is non-nil, find the correct position for the note in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8261 the current entry. If not, assume that it can be inserted at point."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8262 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8263 (when findpos
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8264 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8265 (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8266 "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8267 "[^\r\n]*\\)?"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8268 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8269 (unless org-log-states-order-reversed
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8270 (and (= (char-after) ?\n) (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8271 (org-skip-over-state-notes)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8272 (skip-chars-backward " \t\n\r")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8273 (move-marker org-log-note-marker (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8274 (setq org-log-note-purpose purpose
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8275 org-log-note-state state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8276 org-log-note-how how)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8277 (add-hook 'post-command-hook 'org-add-log-note 'append)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8278
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8279 (defun org-skip-over-state-notes ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8280 "Skip past the list of State notes in an entry."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8281 (if (looking-at "\n[ \t]*- State") (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8282 (while (looking-at "[ \t]*- State")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8283 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8284 (org-next-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8285 (error (org-end-of-item)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8286
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8287 (defun org-add-log-note (&optional purpose)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8288 "Pop up a window for taking a note, and add this note later at point."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8289 (remove-hook 'post-command-hook 'org-add-log-note)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8290 (setq org-log-note-window-configuration (current-window-configuration))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8291 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8292 (move-marker org-log-note-return-to (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8293 (switch-to-buffer (marker-buffer org-log-note-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8294 (goto-char org-log-note-marker)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8295 (org-switch-to-buffer-other-window "*Org Note*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8296 (erase-buffer)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8297 (if (memq org-log-note-how '(time state))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8298 (org-store-log-note)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8299 (let ((org-inhibit-startup t)) (org-mode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8300 (insert (format "# Insert note for %s.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8301 # Finish with C-c C-c, or cancel with C-c C-k.\n\n"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8302 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8303 ((eq org-log-note-purpose 'clock-out) "stopped clock")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8304 ((eq org-log-note-purpose 'done) "closed todo item")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8305 ((eq org-log-note-purpose 'state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8306 (format "state change to \"%s\"" org-log-note-state))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8307 ((eq org-log-note-purpose 'note)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8308 "this entry")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8309 (t (error "This should not happen")))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8310 (org-set-local 'org-finish-function 'org-store-log-note)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8311
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8312 (defvar org-note-abort nil) ; dynamically scoped
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8313 (defun org-store-log-note ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8314 "Finish taking a log note, and insert it to where it belongs."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8315 (let ((txt (buffer-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8316 (note (cdr (assq org-log-note-purpose org-log-note-headings)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8317 lines ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8318 (kill-buffer (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8319 (while (string-match "\\`#.*\n[ \t\n]*" txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8320 (setq txt (replace-match "" t t txt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8321 (if (string-match "\\s-+\\'" txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8322 (setq txt (replace-match "" t t txt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8323 (setq lines (org-split-string txt "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8324 (when (and note (string-match "\\S-" note))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8325 (setq note
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8326 (org-replace-escapes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8327 note
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8328 (list (cons "%u" (user-login-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8329 (cons "%U" user-full-name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8330 (cons "%t" (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8331 (org-time-stamp-format 'long 'inactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8332 (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8333 (cons "%s" (if org-log-note-state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8334 (concat "\"" org-log-note-state "\"")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8335 "")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8336 (if lines (setq note (concat note " \\\\")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8337 (push note lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8338 (when (or current-prefix-arg org-note-abort) (setq lines nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8339 (when lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8340 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8341 (set-buffer (marker-buffer org-log-note-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8342 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8343 (goto-char org-log-note-marker)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8344 (move-marker org-log-note-marker nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8345 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8346 (if (not (bolp)) (let ((inhibit-read-only t)) (insert "\n")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8347 (indent-relative nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8348 (insert "- " (pop lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8349 (org-indent-line-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8350 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8351 (looking-at "[ \t]*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8352 (setq ind (concat (match-string 0) " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8353 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8354 (while lines (insert "\n" ind (pop lines)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8355 (set-window-configuration org-log-note-window-configuration)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8356 (with-current-buffer (marker-buffer org-log-note-return-to)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8357 (goto-char org-log-note-return-to))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8358 (move-marker org-log-note-return-to nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8359 (and org-log-post-message (message "%s" org-log-post-message)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8360
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8361 (defun org-sparse-tree (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8362 "Create a sparse tree, prompt for the details.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8363 This command can create sparse trees. You first need to select the type
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8364 of match used to create the tree:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8365
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8366 t Show entries with a specific TODO keyword.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8367 T Show entries selected by a tags match.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8368 p Enter a property name and its value (both with completion on existing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8369 names/values) and show entries with that property.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8370 r Show entries matching a regular expression
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8371 d Show deadlines due within `org-deadline-warning-days'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8372 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8373 (let (ans kwd value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8374 (message "Sparse tree: [/]regexp [t]odo-kwd [T]ag [p]roperty [d]eadlines [b]efore-date")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8375 (setq ans (read-char-exclusive))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8376 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8377 ((equal ans ?d)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8378 (call-interactively 'org-check-deadlines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8379 ((equal ans ?b)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8380 (call-interactively 'org-check-before-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8381 ((equal ans ?t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8382 (org-show-todo-tree '(4)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8383 ((equal ans ?T)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8384 (call-interactively 'org-tags-sparse-tree))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8385 ((member ans '(?p ?P))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8386 (setq kwd (completing-read "Property: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8387 (mapcar 'list (org-buffer-property-keys))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8388 (setq value (completing-read "Value: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8389 (mapcar 'list (org-property-values kwd))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8390 (unless (string-match "\\`{.*}\\'" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8391 (setq value (concat "\"" value "\"")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8392 (org-tags-sparse-tree arg (concat kwd "=" value)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8393 ((member ans '(?r ?R ?/))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8394 (call-interactively 'org-occur))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8395 (t (error "No such sparse tree command \"%c\"" ans)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8396
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8397 (defvar org-occur-highlights nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8398 "List of overlays used for occur matches.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8399 (make-variable-buffer-local 'org-occur-highlights)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8400 (defvar org-occur-parameters nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8401 "Parameters of the active org-occur calls.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8402 This is a list, each call to org-occur pushes as cons cell,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8403 containing the regular expression and the callback, onto the list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8404 The list can contain several entries if `org-occur' has been called
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8405 several time with the KEEP-PREVIOUS argument. Otherwise, this list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8406 will only contain one set of parameters. When the highlights are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8407 removed (for example with `C-c C-c', or with the next edit (depending
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8408 on `org-remove-highlights-with-change'), this variable is emptied
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8409 as well.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8410 (make-variable-buffer-local 'org-occur-parameters)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8411
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8412 (defun org-occur (regexp &optional keep-previous callback)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8413 "Make a compact tree which shows all matches of REGEXP.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8414 The tree will show the lines where the regexp matches, and all higher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8415 headlines above the match. It will also show the heading after the match,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8416 to make sure editing the matching entry is easy.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8417 If KEEP-PREVIOUS is non-nil, highlighting and exposing done by a previous
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8418 call to `org-occur' will be kept, to allow stacking of calls to this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8419 command.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8420 If CALLBACK is non-nil, it is a function which is called to confirm
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8421 that the match should indeed be shown."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8422 (interactive "sRegexp: \nP")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8423 (unless keep-previous
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8424 (org-remove-occur-highlights nil nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8425 (push (cons regexp callback) org-occur-parameters)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8426 (let ((cnt 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8427 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8428 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8429 (if (or (not keep-previous) ; do not want to keep
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8430 (not org-occur-highlights)) ; no previous matches
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8431 ;; hide everything
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8432 (org-overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8433 (while (re-search-forward regexp nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8434 (when (or (not callback)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8435 (save-match-data (funcall callback)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8436 (setq cnt (1+ cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8437 (when org-highlight-sparse-tree-matches
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8438 (org-highlight-new-match (match-beginning 0) (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8439 (org-show-context 'occur-tree))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8440 (when org-remove-highlights-with-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8441 (org-add-hook 'before-change-functions 'org-remove-occur-highlights
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8442 nil 'local))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8443 (unless org-sparse-tree-open-archived-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8444 (org-hide-archived-subtrees (point-min) (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8445 (run-hooks 'org-occur-hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8446 (if (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8447 (message "%d match(es) for regexp %s" cnt regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8448 cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8449
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8450 (defun org-show-context (&optional key)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8451 "Make sure point and context and visible.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8452 How much context is shown depends upon the variables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8453 `org-show-hierarchy-above', `org-show-following-heading'. and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8454 `org-show-siblings'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8455 (let ((heading-p (org-on-heading-p t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8456 (hierarchy-p (org-get-alist-option org-show-hierarchy-above key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8457 (following-p (org-get-alist-option org-show-following-heading key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8458 (entry-p (org-get-alist-option org-show-entry-below key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8459 (siblings-p (org-get-alist-option org-show-siblings key)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8460 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8461 ;; Show heading or entry text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8462 (if (and heading-p (not entry-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8463 (org-flag-heading nil) ; only show the heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8464 (and (or entry-p (org-invisible-p) (org-invisible-p2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8465 (org-show-hidden-entry))) ; show entire entry
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8466 (when following-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8467 ;; Show next sibling, or heading below text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8468 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8469 (and (if heading-p (org-goto-sibling) (outline-next-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8470 (org-flag-heading nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8471 (when siblings-p (org-show-siblings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8472 (when hierarchy-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8473 ;; show all higher headings, possibly with siblings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8474 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8475 (while (and (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8476 (progn (org-up-heading-all 1) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8477 (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8478 (not (bobp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8479 (org-flag-heading nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8480 (when siblings-p (org-show-siblings))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8481
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8482 (defun org-reveal (&optional siblings)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8483 "Show current entry, hierarchy above it, and the following headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8484 This can be used to show a consistent set of context around locations
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8485 exposed with `org-show-hierarchy-above' or `org-show-following-heading'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8486 not t for the search context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8487
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8488 With optional argument SIBLINGS, on each level of the hierarchy all
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8489 siblings are shown. This repairs the tree structure to what it would
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8490 look like when opened with hierarchical calls to `org-cycle'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8491 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8492 (let ((org-show-hierarchy-above t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8493 (org-show-following-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8494 (org-show-siblings (if siblings t org-show-siblings)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8495 (org-show-context nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8496
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8497 (defun org-highlight-new-match (beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8498 "Highlight from BEG to END and mark the highlight is an occur headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8499 (let ((ov (org-make-overlay beg end)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8500 (org-overlay-put ov 'face 'secondary-selection)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8501 (push ov org-occur-highlights)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8502
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8503 (defun org-remove-occur-highlights (&optional beg end noremove)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8504 "Remove the occur highlights from the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8505 BEG and END are ignored. If NOREMOVE is nil, remove this function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8506 from the `before-change-functions' in the current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8507 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8508 (unless org-inhibit-highlight-removal
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8509 (mapc 'org-delete-overlay org-occur-highlights)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8510 (setq org-occur-highlights nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8511 (setq org-occur-parameters nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8512 (unless noremove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8513 (remove-hook 'before-change-functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8514 'org-remove-occur-highlights 'local))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8515
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8516 ;;;; Priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8517
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8518 (defvar org-priority-regexp ".*?\\(\\[#\\([A-Z0-9]\\)\\] ?\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8519 "Regular expression matching the priority indicator.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8520
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8521 (defvar org-remove-priority-next-time nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8522
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8523 (defun org-priority-up ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8524 "Increase the priority of the current item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8525 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8526 (org-priority 'up))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8527
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8528 (defun org-priority-down ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8529 "Decrease the priority of the current item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8530 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8531 (org-priority 'down))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8532
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8533 (defun org-priority (&optional action)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8534 "Change the priority of an item by ARG.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8535 ACTION can be `set', `up', `down', or a character."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8536 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8537 (setq action (or action 'set))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8538 (let (current new news have remove)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8539 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8540 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8541 (if (looking-at org-priority-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8542 (setq current (string-to-char (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8543 have t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8544 (setq current org-default-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8545 (cond
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8546 ((or (eq action 'set)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8547 (if (featurep 'xemacs) (characterp action) (integerp action)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8548 (if (not (eq action 'set))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8549 (setq new action)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8550 (message "Priority %c-%c, SPC to remove: "
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8551 org-highest-priority org-lowest-priority)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8552 (setq new (read-char-exclusive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8553 (if (and (= (upcase org-highest-priority) org-highest-priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8554 (= (upcase org-lowest-priority) org-lowest-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8555 (setq new (upcase new)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8556 (cond ((equal new ?\ ) (setq remove t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8557 ((or (< (upcase new) org-highest-priority) (> (upcase new) org-lowest-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8558 (error "Priority must be between `%c' and `%c'"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8559 org-highest-priority org-lowest-priority))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8560 ((eq action 'up)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8561 (if (and (not have) (eq last-command this-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8562 (setq new org-lowest-priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8563 (setq new (if (and org-priority-start-cycle-with-default (not have))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8564 org-default-priority (1- current)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8565 ((eq action 'down)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8566 (if (and (not have) (eq last-command this-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8567 (setq new org-highest-priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8568 (setq new (if (and org-priority-start-cycle-with-default (not have))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8569 org-default-priority (1+ current)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8570 (t (error "Invalid action")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8571 (if (or (< (upcase new) org-highest-priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8572 (> (upcase new) org-lowest-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8573 (setq remove t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8574 (setq news (format "%c" new))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8575 (if have
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8576 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8577 (replace-match "" t t nil 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8578 (replace-match news t t nil 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8579 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8580 (error "No priority cookie found in line")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8581 (looking-at org-todo-line-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8582 (if (match-end 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8583 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8584 (goto-char (match-end 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8585 (insert " [#" news "]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8586 (goto-char (match-beginning 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8587 (insert "[#" news "] ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8588 (org-preserve-lc (org-set-tags nil 'align))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8589 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8590 (message "Priority removed")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8591 (message "Priority of current item set to %s" news))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8592
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8593
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8594 (defun org-get-priority (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8595 "Find priority cookie and return priority."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8596 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8597 (if (not (string-match org-priority-regexp s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8598 (* 1000 (- org-lowest-priority org-default-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8599 (* 1000 (- org-lowest-priority
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8600 (string-to-char (match-string 2 s)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8601
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8602 ;;;; Tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8603
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8604 (defun org-scan-tags (action matcher &optional todo-only)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8605 "Scan headline tags with inheritance and produce output ACTION.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8606 ACTION can be `sparse-tree' or `agenda'. MATCHER is a Lisp form to be
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8607 evaluated, testing if a given set of tags qualifies a headline for
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8608 inclusion. When TODO-ONLY is non-nil, only lines with a TODO keyword
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8609 are included in the output."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8610 (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8611 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8612 (org-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8613 "\\>\\)\\)? *\\(.*?\\)\\(:[[:alnum:]_@:]+:\\)?[ \t]*$")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8614 (props (list 'face nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8615 'done-face 'org-done
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8616 'undone-face nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8617 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8618 'org-not-done-regexp org-not-done-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8619 'org-todo-regexp org-todo-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8620 'keymap org-agenda-keymap
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8621 'help-echo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8622 (format "mouse-2 or RET jump to org file %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8623 (abbreviate-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8624 (or (buffer-file-name (buffer-base-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8625 (buffer-name (buffer-base-buffer)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8626 (case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8627 lspos
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8628 tags tags-list tags-alist (llast 0) rtn level category i txt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8629 todo marker entry priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8630 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8631 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8632 (when (eq action 'sparse-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8633 (org-overview)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8634 (org-remove-occur-highlights))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8635 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8636 (catch :skip
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8637 (setq todo (if (match-end 1) (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8638 tags (if (match-end 4) (match-string 4)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8639 (goto-char (setq lspos (1+ (match-beginning 0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8640 (setq level (org-reduced-level (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8641 category (org-get-category))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8642 (setq i llast llast level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8643 ;; remove tag lists from same and sublevels
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8644 (while (>= i level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8645 (when (setq entry (assoc i tags-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8646 (setq tags-alist (delete entry tags-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8647 (setq i (1- i)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8648 ;; add the next tags
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8649 (when tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8650 (setq tags (mapcar 'downcase (org-split-string tags ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8651 tags-alist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8652 (cons (cons level tags) tags-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8653 ;; compile tags for current headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8654 (setq tags-list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8655 (if org-use-tag-inheritance
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8656 (apply 'append (mapcar 'cdr tags-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8657 tags))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8658 (when (and tags org-use-tag-inheritance
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8659 (not (eq t org-use-tag-inheritance)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8660 ;; selective inheritance, remove uninherited ones
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8661 (setcdr (car tags-alist)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8662 (org-remove-uniherited-tags (cdar tags-alist))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8663 (when (and (or (not todo-only) (member todo org-not-done-keywords))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8664 (eval matcher)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8665 (or (not org-agenda-skip-archived-trees)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8666 (not (member org-archive-tag tags-list))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8667 (and (eq action 'agenda) (org-agenda-skip))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8668 ;; list this headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8669
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8670 (if (eq action 'sparse-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8671 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8672 (and org-highlight-sparse-tree-matches
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8673 (org-get-heading) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8674 (org-highlight-new-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8675 (match-beginning 0) (match-beginning 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8676 (org-show-context 'tags-tree))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8677 (setq txt (org-format-agenda-item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8678 ""
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8679 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8680 (if org-tags-match-list-sublevels
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8681 (make-string (1- level) ?.) "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8682 (org-get-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8683 category tags-list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8684 priority (org-get-priority txt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8685 (goto-char lspos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8686 (setq marker (org-agenda-new-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8687 (org-add-props txt props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8688 'org-marker marker 'org-hd-marker marker 'org-category category
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8689 'priority priority 'type "tagsmatch")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8690 (push txt rtn))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8691 ;; if we are to skip sublevels, jump to end of subtree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8692 (or org-tags-match-list-sublevels (org-end-of-subtree t))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8693 (when (and (eq action 'sparse-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8694 (not org-sparse-tree-open-archived-trees))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8695 (org-hide-archived-subtrees (point-min) (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8696 (nreverse rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8697
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8698 (defun org-remove-uniherited-tags (tags)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8699 "Remove all tags that are not inherited from the list TAGS."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8700 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8701 ((eq org-use-tag-inheritance t) tags)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8702 ((not org-use-tag-inheritance) nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8703 ((stringp org-use-tag-inheritance)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8704 (delq nil (mapcar
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8705 (lambda (x) (if (string-match org-use-tag-inheritance x) x nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8706 tags)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8707 ((listp org-use-tag-inheritance)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8708 (org-delete-all org-use-tag-inheritance tags))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8709
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8710 (defvar todo-only) ;; dynamically scoped
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8711
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8712 (defun org-tags-sparse-tree (&optional todo-only match)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8713 "Create a sparse tree according to tags string MATCH.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8714 MATCH can contain positive and negative selection of tags, like
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8715 \"+WORK+URGENT-WITHBOSS\".
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8716 If optional argument TODO_ONLY is non-nil, only select lines that are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8717 also TODO lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8718 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8719 (org-prepare-agenda-buffers (list (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8720 (org-scan-tags 'sparse-tree (cdr (org-make-tags-matcher match)) todo-only))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8721
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8722 (defvar org-cached-props nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8723 (defun org-cached-entry-get (pom property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8724 (if (or (eq t org-use-property-inheritance)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8725 (and (stringp org-use-property-inheritance)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8726 (string-match org-use-property-inheritance property))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8727 (and (listp org-use-property-inheritance)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8728 (member property org-use-property-inheritance)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8729 ;; Caching is not possible, check it directly
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8730 (org-entry-get pom property 'inherit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8731 ;; Get all properties, so that we can do complicated checks easily
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8732 (cdr (assoc property (or org-cached-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8733 (setq org-cached-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8734 (org-entry-properties pom)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8735
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8736 (defun org-global-tags-completion-table (&optional files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8737 "Return the list of all tags in all agenda buffer/files."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8738 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8739 (org-uniquify
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8740 (delq nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8741 (apply 'append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8742 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8743 (lambda (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8744 (set-buffer (find-file-noselect file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8745 (append (org-get-buffer-tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8746 (mapcar (lambda (x) (if (stringp (car-safe x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8747 (list (car-safe x)) nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8748 org-tag-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8749 (if (and files (car files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8750 files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8751 (org-agenda-files))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8752
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8753 (defun org-make-tags-matcher (match)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8754 "Create the TAGS//TODO matcher form for the selection string MATCH."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8755 ;; todo-only is scoped dynamically into this function, and the function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8756 ;; may change it it the matcher asksk for it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8757 (unless match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8758 ;; Get a new match request, with completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8759 (let ((org-last-tags-completion-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8760 (org-global-tags-completion-table)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8761 (setq match (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8762 "Match: " 'org-tags-completion-function nil nil nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8763 'org-tags-history))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8764
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8765 ;; Parse the string and create a lisp form
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8766 (let ((match0 match)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8767 (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)\\([0-9]+\\)\\|\\([[:alnum:]_]+\\)\\([<>=]\\{1,2\\}\\)\\({[^}]+}\\|\"[^\"]*\"\\|-?[.0-9]+\\(?:[eE][-+]?[0-9]+\\)?\\)\\|[[:alnum:]_@]+\\)"))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8768 minus tag mm
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8769 tagsmatch todomatch tagsmatcher todomatcher kwd matcher
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8770 orterms term orlist re-p str-p level-p level-op
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8771 prop-p pn pv po cat-p gv)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8772 (if (string-match "/+" match)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8773 ;; match contains also a todo-matching request
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8774 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8775 (setq tagsmatch (substring match 0 (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8776 todomatch (substring match (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8777 (if (string-match "^!" todomatch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8778 (setq todo-only t todomatch (substring todomatch 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8779 (if (string-match "^\\s-*$" todomatch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8780 (setq todomatch nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8781 ;; only matching tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8782 (setq tagsmatch match todomatch nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8783
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8784 ;; Make the tags matcher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8785 (if (or (not tagsmatch) (not (string-match "\\S-" tagsmatch)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8786 (setq tagsmatcher t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8787 (setq orterms (org-split-string tagsmatch "|") orlist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8788 (while (setq term (pop orterms))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8789 (while (and (equal (substring term -1) "\\") orterms)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8790 (setq term (concat term "|" (pop orterms)))) ; repair bad split
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8791 (while (string-match re term)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8792 (setq minus (and (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8793 (equal (match-string 1 term) "-"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8794 tag (match-string 2 term)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8795 re-p (equal (string-to-char tag) ?{)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8796 level-p (match-end 4)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8797 prop-p (match-end 5)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8798 mm (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8799 (re-p `(org-match-any-p ,(substring tag 1 -1) tags-list))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8800 (level-p
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8801 (setq level-op (org-op-to-function (match-string 3 term)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8802 `(,level-op level ,(string-to-number
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8803 (match-string 4 term))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8804 (prop-p
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8805 (setq pn (match-string 5 term)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8806 po (match-string 6 term)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8807 pv (match-string 7 term)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8808 cat-p (equal pn "CATEGORY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8809 re-p (equal (string-to-char pv) ?{)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8810 str-p (equal (string-to-char pv) ?\")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8811 pv (if (or re-p str-p) (substring pv 1 -1) pv))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8812 (setq po (org-op-to-function po str-p))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8813 (if (equal pn "CATEGORY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8814 (setq gv '(get-text-property (point) 'org-category))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8815 (setq gv `(org-cached-entry-get nil ,pn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8816 (if re-p
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8817 (if (eq po 'org<>)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8818 `(not (string-match ,pv (or ,gv "")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8819 `(string-match ,pv (or ,gv "")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8820 (if str-p
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8821 `(,po (or ,gv "") ,pv)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8822 `(,po (string-to-number (or ,gv ""))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8823 ,(string-to-number pv) ))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8824 (t `(member ,(downcase tag) tags-list)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8825 mm (if minus (list 'not mm) mm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8826 term (substring term (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8827 (push mm tagsmatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8828 (push (if (> (length tagsmatcher) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8829 (cons 'and tagsmatcher)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8830 (car tagsmatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8831 orlist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8832 (setq tagsmatcher nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8833 (setq tagsmatcher (if (> (length orlist) 1) (cons 'or orlist) (car orlist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8834 (setq tagsmatcher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8835 (list 'progn '(setq org-cached-props nil) tagsmatcher)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8836 ;; Make the todo matcher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8837 (if (or (not todomatch) (not (string-match "\\S-" todomatch)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8838 (setq todomatcher t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8839 (setq orterms (org-split-string todomatch "|") orlist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8840 (while (setq term (pop orterms))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8841 (while (string-match re term)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8842 (setq minus (and (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8843 (equal (match-string 1 term) "-"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8844 kwd (match-string 2 term)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8845 re-p (equal (string-to-char kwd) ?{)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8846 term (substring term (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8847 mm (if re-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8848 `(string-match ,(substring kwd 1 -1) todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8849 (list 'equal 'todo kwd))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8850 mm (if minus (list 'not mm) mm))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8851 (push mm todomatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8852 (push (if (> (length todomatcher) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8853 (cons 'and todomatcher)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8854 (car todomatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8855 orlist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8856 (setq todomatcher nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8857 (setq todomatcher (if (> (length orlist) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8858 (cons 'or orlist) (car orlist))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8859
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8860 ;; Return the string and lisp forms of the matcher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8861 (setq matcher (if todomatcher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8862 (list 'and tagsmatcher todomatcher)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8863 tagsmatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8864 (cons match0 matcher)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8865
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8866 (defun org-op-to-function (op &optional stringp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8867 (setq op
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8868 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8869 ((equal op "<" ) '(< string< ))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8870 ((equal op ">" ) '(> org-string> ))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8871 ((member op '("<=" "=<")) '(<= org-string<= ))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8872 ((member op '(">=" "=>")) '(>= org-string>= ))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8873 ((member op '("=" "==")) '(= string= ))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8874 ((member op '("<>" "!=")) '(org<> org-string<> ))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8875 (nth (if stringp 1 0) op))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8876
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8877 (defun org<> (a b) (not (= a b)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8878 (defun org-string<= (a b) (or (string= a b) (string< a b)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8879 (defun org-string>= (a b) (not (string< a b)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8880 (defun org-string> (a b) (and (not (string= a b)) (not (string< a b))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8881 (defun org-string<> (a b) (not (string= a b)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8882
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8883 (defun org-match-any-p (re list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8884 "Does re match any element of list?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8885 (setq list (mapcar (lambda (x) (string-match re x)) list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8886 (delq nil list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8887
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8888 (defvar org-add-colon-after-tag-completion nil) ;; dynamically skoped param
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8889 (defvar org-tags-overlay (org-make-overlay 1 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8890 (org-detach-overlay org-tags-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8891
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8892 (defun org-get-tags-at (&optional pos)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8893 "Get a list of all headline tags applicable at POS.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8894 POS defaults to point. If tags are inherited, the list contains
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8895 the targets in the same sequence as the headlines appear, i.e.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8896 sthe tags of the current headline come last."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8897 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8898 (let (tags ltags lastpos parent)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8899 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8900 (save-restriction
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8901 (widen)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8902 (goto-char (or pos (point)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8903 (save-match-data
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8904 (condition-case nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8905 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8906 (org-back-to-heading t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8907 (while (not (equal lastpos (point)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8908 (setq lastpos (point))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8909 (when (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8910 (setq ltags (org-split-string
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8911 (org-match-string-no-properties 1) ":"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8912 (setq tags (append (org-remove-uniherited-tags ltags)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8913 tags)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8914 (or org-use-tag-inheritance (error ""))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8915 (org-up-heading-all 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8916 (setq parent t)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8917 (error nil))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8918 tags)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8919
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8920 (defun org-toggle-tag (tag &optional onoff)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8921 "Toggle the tag TAG for the current line.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8922 If ONOFF is `on' or `off', don't toggle but set to this state."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8923 (unless (org-on-heading-p t) (error "Not on headling"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8924 (let (res current)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8925 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8926 (beginning-of-line)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8927 (if (re-search-forward (org-re "[ \t]:\\([[:alnum:]_@:]+\\):[ \t]*$")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8928 (point-at-eol) t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8929 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8930 (setq current (match-string 1))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8931 (replace-match ""))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8932 (setq current ""))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8933 (setq current (nreverse (org-split-string current ":")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8934 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8935 ((eq onoff 'on)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8936 (setq res t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8937 (or (member tag current) (push tag current)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8938 ((eq onoff 'off)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8939 (or (not (member tag current)) (setq current (delete tag current))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8940 (t (if (member tag current)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8941 (setq current (delete tag current))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8942 (setq res t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8943 (push tag current))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8944 (end-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8945 (if current
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8946 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8947 (insert " :" (mapconcat 'identity (nreverse current) ":") ":")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8948 (org-set-tags nil t))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8949 (delete-horizontal-space))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8950 (run-hooks 'org-after-tags-change-hook))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8951 res))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8952
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8953 (defun org-align-tags-here (to-col)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8954 ;; Assumes that this is a headline
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8955 (let ((pos (point)) (col (current-column)) ncol tags-l p)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8956 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8957 (if (and (looking-at (org-re ".*?\\([ \t]+\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8958 (< pos (match-beginning 2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8959 (progn
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8960 (setq tags-l (- (match-end 2) (match-beginning 2)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8961 (goto-char (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8962 (insert " ")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8963 (delete-region (point) (1+ (match-beginning 2)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8964 (setq ncol (max (1+ (current-column))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8965 (1+ col)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8966 (if (> to-col 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8967 to-col
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8968 (- (abs to-col) tags-l))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8969 (setq p (point))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8970 (insert (make-string (- ncol (current-column)) ?\ ))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8971 (setq ncol (current-column))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8972 (tabify p (point-at-eol))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8973 (org-move-to-column (min ncol col) t))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8974 (goto-char pos))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8975
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8976 (defun org-set-tags (&optional arg just-align)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8977 "Set the tags for the current headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8978 With prefix ARG, realign all tags in headings in the current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8979 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8980 (let* ((re (concat "^" outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8981 (current (org-get-tags-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8982 (col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8983 (org-setting-tags t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8984 table current-tags inherited-tags ; computed below when needed
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8985 tags p0 c0 c1 rpl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8986 (if arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8987 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8988 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8989 (let ((buffer-invisibility-spec (org-inhibit-invisibility)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8990 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8991 (org-set-tags nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8992 (end-of-line 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8993 (message "All tags realigned to column %d" org-tags-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8994 (if just-align
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8995 (setq tags current)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8996 ;; Get a new set of tags from the user
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8997 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8998 (setq table (or org-tag-alist (org-get-buffer-tags))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8999 org-last-tags-completion-table table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9000 current-tags (org-split-string current ":")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9001 inherited-tags (nreverse
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9002 (nthcdr (length current-tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9003 (nreverse (org-get-tags-at))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9004 tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9005 (if (or (eq t org-use-fast-tag-selection)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9006 (and org-use-fast-tag-selection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9007 (delq nil (mapcar 'cdr table))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9008 (org-fast-tag-selection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9009 current-tags inherited-tags table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9010 (if org-fast-tag-selection-include-todo org-todo-key-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9011 (let ((org-add-colon-after-tag-completion t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9012 (org-trim
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9013 (org-without-partial-completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9014 (completing-read "Tags: " 'org-tags-completion-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9015 nil nil current 'org-tags-history)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9016 (while (string-match "[-+&]+" tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9017 ;; No boolean logic, just a list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9018 (setq tags (replace-match ":" t t tags))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9019
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9020 (if (string-match "\\`[\t ]*\\'" tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9021 (setq tags "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9022 (unless (string-match ":$" tags) (setq tags (concat tags ":")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9023 (unless (string-match "^:" tags) (setq tags (concat ":" tags))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9024
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9025 ;; Insert new tags at the correct column
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9026 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9027 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9028 ((and (equal current "") (equal tags "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9029 ((re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9030 (concat "\\([ \t]*" (regexp-quote current) "\\)[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9031 (point-at-eol) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9032 (if (equal tags "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9033 (setq rpl "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9034 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9035 (setq c0 (current-column) p0 (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9036 c1 (max (1+ c0) (if (> org-tags-column 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9037 org-tags-column
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9038 (- (- org-tags-column) (length tags))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9039 rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9040 (replace-match rpl t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9041 (and (not (featurep 'xemacs)) c0 indent-tabs-mode (tabify p0 (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9042 tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9043 (t (error "Tags alignment failed")))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9044 (org-move-to-column col)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9045 (unless just-align
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9046 (run-hooks 'org-after-tags-change-hook)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9047
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9048 (defun org-change-tag-in-region (beg end tag off)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9049 "Add or remove TAG for each entry in the region.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9050 This works in the agenda, and also in an org-mode buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9051 (interactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9052 (list (region-beginning) (region-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9053 (let ((org-last-tags-completion-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9054 (if (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9055 (org-get-buffer-tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9056 (org-global-tags-completion-table))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9057 (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9058 "Tag: " 'org-tags-completion-function nil nil nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9059 'org-tags-history))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9060 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9061 (message "[s]et or [r]emove? ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9062 (equal (read-char-exclusive) ?r))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9063 (if (fboundp 'deactivate-mark) (deactivate-mark))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9064 (let ((agendap (equal major-mode 'org-agenda-mode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9065 l1 l2 m buf pos newhead (cnt 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9066 (goto-char end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9067 (setq l2 (1- (org-current-line)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9068 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9069 (setq l1 (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9070 (loop for l from l1 to l2 do
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9071 (goto-line l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9072 (setq m (get-text-property (point) 'org-hd-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9073 (when (or (and (org-mode-p) (org-on-heading-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9074 (and agendap m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9075 (setq buf (if agendap (marker-buffer m) (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9076 pos (if agendap m (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9077 (with-current-buffer buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9078 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9079 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9080 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9081 (setq cnt (1+ cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9082 (org-toggle-tag tag (if off 'off 'on))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9083 (setq newhead (org-get-heading)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9084 (and agendap (org-agenda-change-all-lines newhead m))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9085 (message "Tag :%s: %s in %d headings" tag (if off "removed" "set") cnt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9086
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9087 (defun org-tags-completion-function (string predicate &optional flag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9088 (let (s1 s2 rtn (ctable org-last-tags-completion-table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9089 (confirm (lambda (x) (stringp (car x)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9090 (if (string-match "^\\(.*[-+:&|]\\)\\([^-+:&|]*\\)$" string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9091 (setq s1 (match-string 1 string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9092 s2 (match-string 2 string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9093 (setq s1 "" s2 string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9094 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9095 ((eq flag nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9096 ;; try completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9097 (setq rtn (try-completion s2 ctable confirm))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9098 (if (stringp rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9099 (setq rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9100 (concat s1 s2 (substring rtn (length s2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9101 (if (and org-add-colon-after-tag-completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9102 (assoc rtn ctable))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9103 ":" ""))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9104 rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9105 ((eq flag t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9106 ;; all-completions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9107 (all-completions s2 ctable confirm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9108 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9109 ((eq flag 'lambda)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9110 ;; exact match?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9111 (assoc s2 ctable)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9112 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9113
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9114 (defun org-fast-tag-insert (kwd tags face &optional end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9115 "Insert KDW, and the TAGS, the latter with face FACE. Also inser END."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9116 (insert (format "%-12s" (concat kwd ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9117 (org-add-props (mapconcat 'identity tags " ") nil 'face face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9118 (or end "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9119
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9120 (defun org-fast-tag-show-exit (flag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9121 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9122 (goto-line 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9123 (if (re-search-forward "[ \t]+Next change exits" (point-at-eol) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9124 (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9125 (when flag
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9126 (end-of-line 1)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9127 (org-move-to-column (- (window-width) 19) t)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9128 (insert (org-add-props " Next change exits" nil 'face 'org-warning)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9129
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9130 (defun org-set-current-tags-overlay (current prefix)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9131 (let ((s (concat ":" (mapconcat 'identity current ":") ":")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9132 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9133 (org-overlay-display org-tags-overlay (concat prefix s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9134 'secondary-selection)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9135 (put-text-property 0 (length s) 'face '(secondary-selection org-tag) s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9136 (org-overlay-display org-tags-overlay (concat prefix s)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9137
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9138 (defun org-fast-tag-selection (current inherited table &optional todo-table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9139 "Fast tag selection with single keys.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9140 CURRENT is the current list of tags in the headline, INHERITED is the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9141 list of inherited tags, and TABLE is an alist of tags and corresponding keys,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9142 possibly with grouping information. TODO-TABLE is a similar table with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9143 TODO keywords, should these have keys assigned to them.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9144 If the keys are nil, a-z are automatically assigned.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9145 Returns the new tags string, or nil to not change the current settings."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9146 (let* ((fulltable (append table todo-table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9147 (maxlen (apply 'max (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9148 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9149 (if (stringp (car x)) (string-width (car x)) 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9150 fulltable)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9151 (buf (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9152 (expert (eq org-fast-tag-selection-single-key 'expert))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9153 (buffer-tags nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9154 (fwidth (+ maxlen 3 1 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9155 (ncol (/ (- (window-width) 4) fwidth))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9156 (i-face 'org-done)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9157 (c-face 'org-todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9158 tg cnt e c char c1 c2 ntable tbl rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9159 ov-start ov-end ov-prefix
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9160 (exit-after-next org-fast-tag-selection-single-key)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9161 (done-keywords org-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9162 groups ingroup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9163 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9164 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9165 (if (looking-at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9166 (org-re ".*[ \t]\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9167 (setq ov-start (match-beginning 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9168 ov-end (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9169 ov-prefix "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9170 (setq ov-start (1- (point-at-eol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9171 ov-end (1+ ov-start))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9172 (skip-chars-forward "^\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9173 (setq ov-prefix
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9174 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9175 (buffer-substring (1- (point)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9176 (if (> (current-column) org-tags-column)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9177 " "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9178 (make-string (- org-tags-column (current-column)) ?\ ))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9179 (org-move-overlay org-tags-overlay ov-start ov-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9180 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9181 (if expert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9182 (set-buffer (get-buffer-create " *Org tags*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9183 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9184 (split-window-vertically)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9185 (org-switch-to-buffer-other-window (get-buffer-create " *Org tags*")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9186 (erase-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9187 (org-set-local 'org-done-keywords done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9188 (org-fast-tag-insert "Inherited" inherited i-face "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9189 (org-fast-tag-insert "Current" current c-face "\n\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9190 (org-fast-tag-show-exit exit-after-next)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9191 (org-set-current-tags-overlay current ov-prefix)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9192 (setq tbl fulltable char ?a cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9193 (while (setq e (pop tbl))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9194 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9195 ((equal e '(:startgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9196 (push '() groups) (setq ingroup t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9197 (when (not (= cnt 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9198 (setq cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9199 (insert "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9200 (insert "{ "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9201 ((equal e '(:endgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9202 (setq ingroup nil cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9203 (insert "}\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9204 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9205 (setq tg (car e) c2 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9206 (if (cdr e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9207 (setq c (cdr e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9208 ;; automatically assign a character.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9209 (setq c1 (string-to-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9210 (downcase (substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9211 tg (if (= (string-to-char tg) ?@) 1 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9212 (if (or (rassoc c1 ntable) (rassoc c1 table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9213 (while (or (rassoc char ntable) (rassoc char table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9214 (setq char (1+ char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9215 (setq c2 c1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9216 (setq c (or c2 char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9217 (if ingroup (push tg (car groups)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9218 (setq tg (org-add-props tg nil 'face
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9219 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9220 ((not (assoc tg table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9221 (org-get-todo-face tg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9222 ((member tg current) c-face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9223 ((member tg inherited) i-face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9224 (t nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9225 (if (and (= cnt 0) (not ingroup)) (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9226 (insert "[" c "] " tg (make-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9227 (- fwidth 4 (length tg)) ?\ ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9228 (push (cons tg c) ntable)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9229 (when (= (setq cnt (1+ cnt)) ncol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9230 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9231 (if ingroup (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9232 (setq cnt 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9233 (setq ntable (nreverse ntable))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9234 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9235 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9236 (if (and (not expert) (fboundp 'fit-window-to-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9237 (fit-window-to-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9238 (setq rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9239 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9240 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9241 (message "[a-z..]:Toggle [SPC]:clear [RET]:accept [TAB]:free%s%s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9242 (if groups " [!] no groups" " [!]groups")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9243 (if expert " [C-c]:window" (if exit-after-next " [C-c]:single" " [C-c]:multi")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9244 (setq c (let ((inhibit-quit t)) (read-char-exclusive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9245 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9246 ((= c ?\r) (throw 'exit t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9247 ((= c ?!)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9248 (setq groups (not groups))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9249 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9250 (while (re-search-forward "[{}]" nil t) (replace-match " ")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9251 ((= c ?\C-c)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9252 (if (not expert)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9253 (org-fast-tag-show-exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9254 (setq exit-after-next (not exit-after-next)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9255 (setq expert nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9256 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9257 (split-window-vertically)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9258 (org-switch-to-buffer-other-window " *Org tags*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9259 (and (fboundp 'fit-window-to-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9260 (fit-window-to-buffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9261 ((or (= c ?\C-g)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9262 (and (= c ?q) (not (rassoc c ntable))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9263 (org-detach-overlay org-tags-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9264 (setq quit-flag t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9265 ((= c ?\ )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9266 (setq current nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9267 (if exit-after-next (setq exit-after-next 'now)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9268 ((= c ?\t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9269 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9270 (setq tg (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9271 "Tag: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9272 (or buffer-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9273 (with-current-buffer buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9274 (org-get-buffer-tags)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9275 (quit (setq tg "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9276 (when (string-match "\\S-" tg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9277 (add-to-list 'buffer-tags (list tg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9278 (if (member tg current)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9279 (setq current (delete tg current))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9280 (push tg current)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9281 (if exit-after-next (setq exit-after-next 'now)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9282 ((setq e (rassoc c todo-table) tg (car e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9283 (with-current-buffer buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9284 (save-excursion (org-todo tg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9285 (if exit-after-next (setq exit-after-next 'now)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9286 ((setq e (rassoc c ntable) tg (car e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9287 (if (member tg current)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9288 (setq current (delete tg current))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9289 (loop for g in groups do
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9290 (if (member tg g)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9291 (mapc (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9292 (setq current (delete x current)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9293 g)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9294 (push tg current))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9295 (if exit-after-next (setq exit-after-next 'now))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9296
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9297 ;; Create a sorted list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9298 (setq current
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9299 (sort current
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9300 (lambda (a b)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9301 (assoc b (cdr (memq (assoc a ntable) ntable))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9302 (if (eq exit-after-next 'now) (throw 'exit t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9303 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9304 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9305 (delete-region (point) (point-at-eol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9306 (org-fast-tag-insert "Current" current c-face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9307 (org-set-current-tags-overlay current ov-prefix)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9308 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9309 (org-re "\\[.\\] \\([[:alnum:]_@]+\\)") nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9310 (setq tg (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9311 (add-text-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9312 (match-beginning 1) (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9313 (list 'face
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9314 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9315 ((member tg current) c-face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9316 ((member tg inherited) i-face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9317 (t (get-text-property (match-beginning 1) 'face))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9318 (goto-char (point-min)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9319 (org-detach-overlay org-tags-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9320 (if rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9321 (mapconcat 'identity current ":")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9322 nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9323
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9324 (defun org-get-tags-string ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9325 "Get the TAGS string in the current headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9326 (unless (org-on-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9327 (error "Not on a heading"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9328 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9329 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9330 (if (looking-at (org-re ".*[ \t]\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9331 (org-match-string-no-properties 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9332 "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9333
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9334 (defun org-get-tags ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9335 "Get the list of tags specified in the current headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9336 (org-split-string (org-get-tags-string) ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9337
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9338 (defun org-get-buffer-tags ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9339 "Get a table of all tags used in the buffer, for completion."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9340 (let (tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9341 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9342 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9343 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9344 (org-re "[ \t]:\\([[:alnum:]_@:]+\\):[ \t\r\n]") nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9345 (when (equal (char-after (point-at-bol 0)) ?*)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9346 (mapc (lambda (x) (add-to-list 'tags x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9347 (org-split-string (org-match-string-no-properties 1) ":")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9348 (mapcar 'list tags)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9349
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9350
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9351 ;;;; Properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9352
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9353 ;;; Setting and retrieving properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9354
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9355 (defconst org-special-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9356 '("TODO" "TAGS" "ALLTAGS" "DEADLINE" "SCHEDULED" "CLOCK" "PRIORITY"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9357 "TIMESTAMP" "TIMESTAMP_IA")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9358 "The special properties valid in Org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9359
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9360 These are properties that are not defined in the property drawer,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9361 but in some other way.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9362
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9363 (defconst org-default-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9364 '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9365 "LOCATION" "LOGGING" "COLUMNS")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9366 "Some properties that are used by Org-mode for various purposes.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9367 Being in this list makes sure that they are offered for completion.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9368
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9369 (defconst org-property-start-re "^[ \t]*:PROPERTIES:[ \t]*$"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9370 "Regular expression matching the first line of a property drawer.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9371
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9372 (defconst org-property-end-re "^[ \t]*:END:[ \t]*$"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9373 "Regular expression matching the first line of a property drawer.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9374
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9375 (defun org-property-action ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9376 "Do an action on properties."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9377 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9378 (let (c)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9379 (org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9380 (message "Property Action: [s]et [d]elete [D]elete globally [c]ompute")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9381 (setq c (read-char-exclusive))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9382 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9383 ((equal c ?s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9384 (call-interactively 'org-set-property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9385 ((equal c ?d)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9386 (call-interactively 'org-delete-property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9387 ((equal c ?D)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9388 (call-interactively 'org-delete-property-globally))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9389 ((equal c ?c)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9390 (call-interactively 'org-compute-property-at-point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9391 (t (error "No such property action %c" c)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9392
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9393 (defun org-at-property-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9394 "Is the cursor in a property line?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9395 ;; FIXME: Does not check if we are actually in the drawer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9396 ;; FIXME: also returns true on any drawers.....
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9397 ;; This is used by C-c C-c for property action.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9398 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9399 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9400 (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9401
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9402 (defun org-get-property-block (&optional beg end force)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9403 "Return the (beg . end) range of the body of the property drawer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9404 BEG and END can be beginning and end of subtree, if not given
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9405 they will be found.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9406 If the drawer does not exist and FORCE is non-nil, create the drawer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9407 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9408 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9409 (let* ((beg (or beg (progn (org-back-to-heading t) (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9410 (end (or end (progn (outline-next-heading) (point)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9411 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9412 (if (re-search-forward org-property-start-re end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9413 (setq beg (1+ (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9414 (if force
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9415 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9416 (org-insert-property-drawer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9417 (setq end (progn (outline-next-heading) (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9418 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9419 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9420 (if (re-search-forward org-property-start-re end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9421 (setq beg (1+ (match-end 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9422 (if (re-search-forward org-property-end-re end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9423 (setq end (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9424 (or force (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9425 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9426 (setq end beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9427 (org-indent-line-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9428 (insert ":END:\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9429 (cons beg end)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9430
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9431 (defun org-entry-properties (&optional pom which)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9432 "Get all properties of the entry at point-or-marker POM.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9433 This includes the TODO keyword, the tags, time strings for deadline,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9434 scheduled, and clocking, and any additional properties defined in the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9435 entry. The return value is an alist, keys may occur multiple times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9436 if the property key was used several times.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9437 POM may also be nil, in which case the current entry is used.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9438 If WHICH is nil or `all', get all properties. If WHICH is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9439 `special' or `standard', only get that subclass."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9440 (setq which (or which 'all))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9441 (org-with-point-at pom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9442 (let ((clockstr (substring org-clock-string 0 -1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9443 (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9444 beg end range props sum-props key value string clocksum)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9445 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9446 (when (condition-case nil (org-back-to-heading t) (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9447 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9448 (setq sum-props (get-text-property (point) 'org-summaries))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9449 (setq clocksum (get-text-property (point) :org-clock-minutes))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9450 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9451 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9452 (when (memq which '(all special))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9453 ;; Get the special properties, like TODO and tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9454 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9455 (when (and (looking-at org-todo-line-regexp) (match-end 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9456 (push (cons "TODO" (org-match-string-no-properties 2)) props))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9457 (when (looking-at org-priority-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9458 (push (cons "PRIORITY" (org-match-string-no-properties 2)) props))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9459 (when (and (setq value (org-get-tags-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9460 (string-match "\\S-" value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9461 (push (cons "TAGS" value) props))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9462 (when (setq value (org-get-tags-at))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9463 (push (cons "ALLTAGS" (concat ":" (mapconcat 'identity value ":") ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9464 props))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9465 (while (re-search-forward org-maybe-keyword-time-regexp end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9466 (setq key (if (match-end 1) (substring (org-match-string-no-properties 1) 0 -1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9467 string (if (equal key clockstr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9468 (org-no-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9469 (org-trim
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9470 (buffer-substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9471 (match-beginning 3) (goto-char (point-at-eol)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9472 (substring (org-match-string-no-properties 3) 1 -1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9473 (unless key
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9474 (if (= (char-after (match-beginning 3)) ?\[)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9475 (setq key "TIMESTAMP_IA")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9476 (setq key "TIMESTAMP")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9477 (when (or (equal key clockstr) (not (assoc key props)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9478 (push (cons key string) props)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9479
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9480 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9481
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9482 (when (memq which '(all standard))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9483 ;; Get the standard properties, like :PORP: ...
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9484 (setq range (org-get-property-block beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9485 (when range
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9486 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9487 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9488 (org-re "^[ \t]*:\\([[:alpha:]][[:alnum:]_-]*\\):[ \t]*\\(\\S-.*\\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9489 (cdr range) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9490 (setq key (org-match-string-no-properties 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9491 value (org-trim (or (org-match-string-no-properties 2) "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9492 (unless (member key excluded)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9493 (push (cons key (or value "")) props)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9494 (if clocksum
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9495 (push (cons "CLOCKSUM"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9496 (org-columns-number-to-string (/ (float clocksum) 60.)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9497 'add_times))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9498 props))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9499 (append sum-props (nreverse props)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9500
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9501 (defun org-entry-get (pom property &optional inherit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9502 "Get value of PROPERTY for entry at point-or-marker POM.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9503 If INHERIT is non-nil and the entry does not have the property,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9504 then also check higher levels of the hierarchy.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9505 If INHERIT is the symbol `selective', use inheritance only if the setting
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9506 in `org-use-property-inheritance' selects PROPERTY for inheritance.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9507 If the property is present but empty, the return value is the empty string.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9508 If the property is not present at all, nil is returned."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9509 (org-with-point-at pom
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9510 (if (and inherit (if (eq inherit 'selective)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9511 (org-property-inherit-p property)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9512 t))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9513 (org-entry-get-with-inheritance property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9514 (if (member property org-special-properties)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9515 ;; We need a special property. Use brute force, get all properties.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9516 (cdr (assoc property (org-entry-properties nil 'special)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9517 (let ((range (org-get-property-block)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9518 (if (and range
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9519 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9520 (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9521 (concat "^[ \t]*:" property ":[ \t]*\\(.*\\S-\\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9522 (cdr range) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9523 ;; Found the property, return it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9524 (if (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9525 (org-match-string-no-properties 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9526 "")))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9527
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9528 (defun org-property-or-variable-value (var &optional inherit)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9529 "Check if there is a property fixing the value of VAR.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9530 If yes, return this value. If not, return the current value of the variable."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9531 (let ((prop (org-entry-get nil (symbol-name var) inherit)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9532 (if (and prop (stringp prop) (string-match "\\S-" prop))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9533 (read prop)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9534 (symbol-value var))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9535
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9536 (defun org-entry-delete (pom property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9537 "Delete the property PROPERTY from entry at point-or-marker POM."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9538 (org-with-point-at pom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9539 (if (member property org-special-properties)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9540 nil ; cannot delete these properties.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9541 (let ((range (org-get-property-block)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9542 (if (and range
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9543 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9544 (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9545 (concat "^[ \t]*:" property ":[ \t]*\\(.*\\S-\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9546 (cdr range) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9547 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9548 (delete-region (match-beginning 0) (1+ (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9549 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9550 nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9551
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9552 ;; Multi-values properties are properties that contain multiple values
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9553 ;; These values are assumed to be single words, separated by whitespace.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9554 (defun org-entry-add-to-multivalued-property (pom property value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9555 "Add VALUE to the words in the PROPERTY in entry at point-or-marker POM."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9556 (let* ((old (org-entry-get pom property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9557 (values (and old (org-split-string old "[ \t]"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9558 (unless (member value values)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9559 (setq values (cons value values))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9560 (org-entry-put pom property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9561 (mapconcat 'identity values " ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9562
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9563 (defun org-entry-remove-from-multivalued-property (pom property value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9564 "Remove VALUE from words in the PROPERTY in entry at point-or-marker POM."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9565 (let* ((old (org-entry-get pom property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9566 (values (and old (org-split-string old "[ \t]"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9567 (when (member value values)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9568 (setq values (delete value values))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9569 (org-entry-put pom property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9570 (mapconcat 'identity values " ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9571
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9572 (defun org-entry-member-in-multivalued-property (pom property value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9573 "Is VALUE one of the words in the PROPERTY in entry at point-or-marker POM?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9574 (let* ((old (org-entry-get pom property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9575 (values (and old (org-split-string old "[ \t]"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9576 (member value values)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9577
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9578 (defvar org-entry-property-inherited-from (make-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9579
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9580 (defun org-entry-get-with-inheritance (property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9581 "Get entry property, and search higher levels if not present."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9582 (let (tmp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9583 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9584 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9585 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9586 (catch 'ex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9587 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9588 (when (setq tmp (org-entry-get nil property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9589 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9590 (move-marker org-entry-property-inherited-from (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9591 (throw 'ex tmp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9592 (or (org-up-heading-safe) (throw 'ex nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9593 (or tmp (cdr (assoc property org-local-properties))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9594 (cdr (assoc property org-global-properties))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9595
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9596 (defun org-entry-put (pom property value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9597 "Set PROPERTY to VALUE for entry at point-or-marker POM."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9598 (org-with-point-at pom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9599 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9600 (let ((beg (point)) (end (save-excursion (outline-next-heading) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9601 range)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9602 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9603 ((equal property "TODO")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9604 (when (and (stringp value) (string-match "\\S-" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9605 (not (member value org-todo-keywords-1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9606 (error "\"%s\" is not a valid TODO state" value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9607 (if (or (not value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9608 (not (string-match "\\S-" value)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9609 (setq value 'none))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9610 (org-todo value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9611 (org-set-tags nil 'align))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9612 ((equal property "PRIORITY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9613 (org-priority (if (and value (stringp value) (string-match "\\S-" value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9614 (string-to-char value) ?\ ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9615 (org-set-tags nil 'align))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9616 ((equal property "SCHEDULED")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9617 (if (re-search-forward org-scheduled-time-regexp end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9618 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9619 ((eq value 'earlier) (org-timestamp-change -1 'day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9620 ((eq value 'later) (org-timestamp-change 1 'day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9621 (t (call-interactively 'org-schedule)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9622 (call-interactively 'org-schedule)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9623 ((equal property "DEADLINE")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9624 (if (re-search-forward org-deadline-time-regexp end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9625 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9626 ((eq value 'earlier) (org-timestamp-change -1 'day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9627 ((eq value 'later) (org-timestamp-change 1 'day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9628 (t (call-interactively 'org-deadline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9629 (call-interactively 'org-deadline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9630 ((member property org-special-properties)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9631 (error "The %s property can not yet be set with `org-entry-put'"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9632 property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9633 (t ; a non-special property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9634 (let ((buffer-invisibility-spec (org-inhibit-invisibility))) ; Emacs 21
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9635 (setq range (org-get-property-block beg end 'force))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9636 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9637 (if (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9638 (concat "^[ \t]*:" property ":\\(.*\\)") (cdr range) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9639 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9640 (delete-region (match-beginning 1) (match-end 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9641 (goto-char (match-beginning 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9642 (goto-char (cdr range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9643 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9644 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9645 (org-indent-line-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9646 (insert ":" property ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9647 (and value (insert " " value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9648 (org-indent-line-function)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9649
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9650 (defun org-buffer-property-keys (&optional include-specials include-defaults include-columns)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9651 "Get all property keys in the current buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9652 With INCLUDE-SPECIALS, also list the special properties that relect things
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9653 like tags and TODO state.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9654 With INCLUDE-DEFAULTS, also include properties that has special meaning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9655 internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9656 With INCLUDE-COLUMNS, also include property names given in COLUMN
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9657 formats in the current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9658 (let (rtn range cfmt cols s p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9659 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9660 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9661 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9662 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9663 (while (re-search-forward org-property-start-re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9664 (setq range (org-get-property-block))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9665 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9666 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9667 (org-re "^[ \t]*:\\([-[:alnum:]_]+\\):")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9668 (cdr range) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9669 (add-to-list 'rtn (org-match-string-no-properties 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9670 (outline-next-heading))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9671
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9672 (when include-specials
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9673 (setq rtn (append org-special-properties rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9674
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9675 (when include-defaults
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9676 (mapc (lambda (x) (add-to-list 'rtn x)) org-default-properties))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9677
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9678 (when include-columns
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9679 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9680 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9681 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9682 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9683 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9684 "^\\(#\\+COLUMNS:\\|[ \t]*:COLUMNS:\\)[ \t]*\\(.*\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9685 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9686 (setq cfmt (match-string 2) s 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9687 (while (string-match (org-re "%[0-9]*\\([-[:alnum:]_]+\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9688 cfmt s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9689 (setq s (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9690 p (match-string 1 cfmt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9691 (unless (or (equal p "ITEM")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9692 (member p org-special-properties))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9693 (add-to-list 'rtn (match-string 1 cfmt))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9694
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9695 (sort rtn (lambda (a b) (string< (upcase a) (upcase b))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9696
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9697 (defun org-property-values (key)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9698 "Return a list of all values of property KEY."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9699 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9700 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9701 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9702 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9703 (let ((re (concat "^[ \t]*:" key ":[ \t]*\\(\\S-.*\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9704 values)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9705 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9706 (add-to-list 'values (org-trim (match-string 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9707 (delete "" values)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9708
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9709 (defun org-insert-property-drawer ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9710 "Insert a property drawer into the current entry."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9711 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9712 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9713 (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9714 (let ((indent (- (match-end 0)(match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9715 (beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9716 (re (concat "^[ \t]*" org-keyword-time-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9717 end hiddenp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9718 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9719 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9720 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9721 (while (re-search-forward re end t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9722 (setq hiddenp (org-invisible-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9723 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9724 (and (equal (char-after) ?\n) (forward-char 1))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9725 (while (looking-at "^[ \t]*\\(:CLOCK:\\|CLOCK\\|:END:\\)")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9726 (beginning-of-line 2))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9727 (org-skip-over-state-notes)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9728 (skip-chars-backward " \t\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9729 (if (eq (char-before) ?*) (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9730 (let ((inhibit-read-only t)) (insert "\n:PROPERTIES:\n:END:"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9731 (beginning-of-line 0)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9732 (org-indent-to-column indent)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9733 (beginning-of-line 2)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9734 (org-indent-to-column indent)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9735 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9736 (if hiddenp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9737 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9738 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9739 (hide-entry))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9740 (org-flag-drawer t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9741
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9742 (defun org-set-property (property value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9743 "In the current entry, set PROPERTY to VALUE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9744 When called interactively, this will prompt for a property name, offering
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9745 completion on existing and default properties. And then it will prompt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9746 for a value, offering competion either on allowed values (via an inherited
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9747 xxx_ALL property) or on existing values in other instances of this property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9748 in the current file."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9749 (interactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9750 (let* ((prop (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9751 "Property: " (mapcar 'list (org-buffer-property-keys nil t t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9752 (cur (org-entry-get nil prop))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9753 (allowed (org-property-get-allowed-values nil prop 'table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9754 (existing (mapcar 'list (org-property-values prop)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9755 (val (if allowed
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9756 (completing-read "Value: " allowed nil 'req-match)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9757 (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9758 (concat "Value" (if (and cur (string-match "\\S-" cur))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9759 (concat "[" cur "]") "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9760 ": ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9761 existing nil nil "" nil cur))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9762 (list prop (if (equal val "") cur val))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9763 (unless (equal (org-entry-get nil property) value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9764 (org-entry-put nil property value)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9765
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9766 (defun org-delete-property (property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9767 "In the current entry, delete PROPERTY."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9768 (interactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9769 (let* ((prop (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9770 "Property: " (org-entry-properties nil 'standard))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9771 (list prop)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9772 (message "Property %s %s" property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9773 (if (org-entry-delete nil property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9774 "deleted"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9775 "was not present in the entry")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9776
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9777 (defun org-delete-property-globally (property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9778 "Remove PROPERTY globally, from all entries."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9779 (interactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9780 (let* ((prop (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9781 "Globally remove property: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9782 (mapcar 'list (org-buffer-property-keys)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9783 (list prop)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9784 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9785 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9786 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9787 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9788 (let ((cnt 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9789 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9790 (concat "^[ \t]*:" (regexp-quote property) ":.*\n?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9791 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9792 (setq cnt (1+ cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9793 (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9794 (message "Property \"%s\" removed from %d entries" property cnt)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9795
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9796 (defvar org-columns-current-fmt-compiled) ; defined in org-colview.el
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9797
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9798 (defun org-compute-property-at-point ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9799 "Compute the property at point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9800 This looks for an enclosing column format, extracts the operator and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9801 then applies it to the proerty in the column format's scope."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9802 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9803 (unless (org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9804 (error "Not at a property"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9805 (let ((prop (org-match-string-no-properties 2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9806 (org-columns-get-format-and-top-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9807 (unless (nth 3 (assoc prop org-columns-current-fmt-compiled))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9808 (error "No operator defined for property %s" prop))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9809 (org-columns-compute prop)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9810
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9811 (defun org-property-get-allowed-values (pom property &optional table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9812 "Get allowed values for the property PROPERTY.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9813 When TABLE is non-nil, return an alist that can directly be used for
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9814 completion."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9815 (let (vals)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9816 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9817 ((equal property "TODO")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9818 (setq vals (org-with-point-at pom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9819 (append org-todo-keywords-1 '("")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9820 ((equal property "PRIORITY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9821 (let ((n org-lowest-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9822 (while (>= n org-highest-priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9823 (push (char-to-string n) vals)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9824 (setq n (1- n)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9825 ((member property org-special-properties))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9826 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9827 (setq vals (org-entry-get pom (concat property "_ALL") 'inherit))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9828
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9829 (when (and vals (string-match "\\S-" vals))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9830 (setq vals (car (read-from-string (concat "(" vals ")"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9831 (setq vals (mapcar (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9832 (cond ((stringp x) x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9833 ((numberp x) (number-to-string x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9834 ((symbolp x) (symbol-name x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9835 (t "???")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9836 vals)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9837 (if table (mapcar 'list vals) vals)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9838
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9839 (defun org-property-previous-allowed-value (&optional previous)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9840 "Switch to the next allowed value for this property."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9841 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9842 (org-property-next-allowed-value t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9843
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9844 (defun org-property-next-allowed-value (&optional previous)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9845 "Switch to the next allowed value for this property."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9846 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9847 (unless (org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9848 (error "Not at a property"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9849 (let* ((key (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9850 (value (match-string 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9851 (allowed (or (org-property-get-allowed-values (point) key)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9852 (and (member value '("[ ]" "[-]" "[X]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9853 '("[ ]" "[X]"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9854 nval)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9855 (unless allowed
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9856 (error "Allowed values for this property have not been defined"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9857 (if previous (setq allowed (reverse allowed)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9858 (if (member value allowed)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9859 (setq nval (car (cdr (member value allowed)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9860 (setq nval (or nval (car allowed)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9861 (if (equal nval value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9862 (error "Only one allowed value for this property"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9863 (org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9864 (replace-match (concat " :" key ": " nval) t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9865 (org-indent-line-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9866 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9867 (skip-chars-forward " \t")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9868
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9869 (defun org-find-entry-with-id (ident)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9870 "Locate the entry that contains the ID property with exact value IDENT.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9871 IDENT can be a string, a symbol or a number, this function will search for
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9872 the string representation of it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9873 Return the position where this entry starts, or nil if there is no such entry."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9874 (let ((id (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9875 ((stringp ident) ident)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9876 ((symbol-name ident) (symbol-name ident))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9877 ((numberp ident) (number-to-string ident))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9878 (t (error "IDENT %s must be a string, symbol or number" ident))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9879 (case-fold-search nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9880 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9881 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9882 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9883 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9884 (when (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9885 (concat "^[ \t]*:ID:[ \t]+" (regexp-quote id) "[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9886 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9887 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9888 (point))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9889
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9890 ;;;; Timestamps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9891
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9892 (defvar org-last-changed-timestamp nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9893 (defvar org-time-was-given) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9894 (defvar org-end-time-was-given) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9895 (defvar org-ts-what) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9896
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9897 (defun org-time-stamp (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9898 "Prompt for a date/time and insert a time stamp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9899 If the user specifies a time like HH:MM, or if this command is called
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9900 with a prefix argument, the time stamp will contain date and time.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9901 Otherwise, only the date will be included. All parts of a date not
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9902 specified by the user will be filled in from the current date/time.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9903 So if you press just return without typing anything, the time stamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9904 will represent the current date/time. If there is already a timestamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9905 at the cursor, it will be modified."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9906 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9907 (let* ((ts nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9908 (default-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9909 ;; Default time is either today, or, when entering a range,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9910 ;; the range start.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9911 (if (or (and (org-at-timestamp-p t) (setq ts (match-string 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9912 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9913 (re-search-backward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9914 (concat org-ts-regexp "--?-?\\=") ; 1-3 minuses
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9915 (- (point) 20) t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9916 (apply 'encode-time (org-parse-time-string (match-string 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9917 (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9918 (default-input (and ts (org-get-compact-tod ts)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9919 org-time-was-given org-end-time-was-given time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9920 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9921 ((and (org-at-timestamp-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9922 (eq last-command 'org-time-stamp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9923 (eq this-command 'org-time-stamp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9924 (insert "--")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9925 (setq time (let ((this-command this-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9926 (org-read-date arg 'totime nil nil default-time default-input)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9927 (org-insert-time-stamp time (or org-time-was-given arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9928 ((org-at-timestamp-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9929 (setq time (let ((this-command this-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9930 (org-read-date arg 'totime nil nil default-time default-input)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9931 (when (org-at-timestamp-p) ; just to get the match data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9932 (replace-match "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9933 (setq org-last-changed-timestamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9934 (org-insert-time-stamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9935 time (or org-time-was-given arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9936 nil nil nil (list org-end-time-was-given))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9937 (message "Timestamp updated"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9938 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9939 (setq time (let ((this-command this-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9940 (org-read-date arg 'totime nil nil default-time default-input)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9941 (org-insert-time-stamp time (or org-time-was-given arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9942 nil nil nil (list org-end-time-was-given))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9943
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9944 ;; FIXME: can we use this for something else, like computing time differences?
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9945 (defun org-get-compact-tod (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9946 (when (string-match "\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\(-\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\)?" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9947 (let* ((t1 (match-string 1 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9948 (h1 (string-to-number (match-string 2 s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9949 (m1 (string-to-number (match-string 3 s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9950 (t2 (and (match-end 4) (match-string 5 s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9951 (h2 (and t2 (string-to-number (match-string 6 s))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9952 (m2 (and t2 (string-to-number (match-string 7 s))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9953 dh dm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9954 (if (not t2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9955 t1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9956 (setq dh (- h2 h1) dm (- m2 m1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9957 (if (< dm 0) (setq dm (+ dm 60) dh (1- dh)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9958 (concat t1 "+" (number-to-string dh)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9959 (if (/= 0 dm) (concat ":" (number-to-string dm))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9960
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9961 (defun org-time-stamp-inactive (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9962 "Insert an inactive time stamp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9963 An inactive time stamp is enclosed in square brackets instead of angle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9964 brackets. It is inactive in the sense that it does not trigger agenda entries,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9965 does not link to the calendar and cannot be changed with the S-cursor keys.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9966 So these are more for recording a certain time/date."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9967 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9968 (let (org-time-was-given org-end-time-was-given time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9969 (setq time (org-read-date arg 'totime))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9970 (org-insert-time-stamp time (or org-time-was-given arg) 'inactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9971 nil nil (list org-end-time-was-given))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9972
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9973 (defvar org-date-ovl (org-make-overlay 1 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9974 (org-overlay-put org-date-ovl 'face 'org-warning)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9975 (org-detach-overlay org-date-ovl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9976
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9977 (defvar org-ans1) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9978 (defvar org-ans2) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9979
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9980 (defvar org-plain-time-of-day-regexp) ; defined below
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9981
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9982 (defvar org-read-date-overlay nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9983 (defvar org-dcst nil) ; dynamically scoped
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9984
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9985 (defun org-read-date (&optional with-time to-time from-string prompt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9986 default-time default-input)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9987 "Read a date, possibly a time, and make things smooth for the user.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9988 The prompt will suggest to enter an ISO date, but you can also enter anything
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9989 which will at least partially be understood by `parse-time-string'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9990 Unrecognized parts of the date will default to the current day, month, year,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9991 hour and minute. If this command is called to replace a timestamp at point,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9992 of to enter the second timestamp of a range, the default time is taken from the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9993 existing stamp. For example,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9994 3-2-5 --> 2003-02-05
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9995 feb 15 --> currentyear-02-15
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9996 sep 12 9 --> 2009-09-12
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9997 12:45 --> today 12:45
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9998 22 sept 0:34 --> currentyear-09-22 0:34
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9999 12 --> currentyear-currentmonth-12
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10000 Fri --> nearest Friday (today or later)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10001 etc.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10002
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10003 Furthermore you can specify a relative date by giving, as the *first* thing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10004 in the input: a plus/minus sign, a number and a letter [dwmy] to indicate
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10005 change in days weeks, months, years.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10006 With a single plus or minus, the date is relative to today. With a double
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10007 plus or minus, it is relative to the date in DEFAULT-TIME. E.g.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10008 +4d --> four days from today
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10009 +4 --> same as above
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10010 +2w --> two weeks from today
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10011 ++5 --> five days from default date
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10012
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10013 The function understands only English month and weekday abbreviations,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10014 but this can be configured with the variables `parse-time-months' and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10015 `parse-time-weekdays'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10016
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10017 While prompting, a calendar is popped up - you can also select the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10018 date with the mouse (button 1). The calendar shows a period of three
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10019 months. To scroll it to other months, use the keys `>' and `<'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10020 If you don't like the calendar, turn it off with
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10021 \(setq org-read-date-popup-calendar nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10022
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10023 With optional argument TO-TIME, the date will immediately be converted
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10024 to an internal time.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10025 With an optional argument WITH-TIME, the prompt will suggest to also
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10026 insert a time. Note that when WITH-TIME is not set, you can still
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10027 enter a time, and this function will inform the calling routine about
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10028 this change. The calling routine may then choose to change the format
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10029 used to insert the time stamp into the buffer to include the time.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10030 With optional argument FROM-STRING, read from this string instead from
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10031 the user. PROMPT can overwrite the default prompt. DEFAULT-TIME is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10032 the time/date that is used for everything that is not specified by the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10033 user."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10034 (require 'parse-time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10035 (let* ((org-time-stamp-rounding-minutes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10036 (if (equal with-time '(16)) '(0 0) org-time-stamp-rounding-minutes))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10037 (org-dcst org-display-custom-times)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10038 (ct (org-current-time))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10039 (def (or default-time ct))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10040 (defdecode (decode-time def))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10041 (dummy (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10042 (when (< (nth 2 defdecode) org-extend-today-until)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10043 (setcar (nthcdr 2 defdecode) -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10044 (setcar (nthcdr 1 defdecode) 59)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10045 (setq def (apply 'encode-time defdecode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10046 defdecode (decode-time def)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10047 (calendar-move-hook nil)
93810
ba0874919ac4 (org-agenda-format-date-aligned, org-agenda-execute-calendar-command):
Glenn Morris <rgm@gnu.org>
parents: 93141
diff changeset
10048 (calendar-view-diary-initially-flag nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10049 (view-diary-entries-initially nil)
93810
ba0874919ac4 (org-agenda-format-date-aligned, org-agenda-execute-calendar-command):
Glenn Morris <rgm@gnu.org>
parents: 93141
diff changeset
10050 (calendar-view-holidays-initially-flag nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10051 (view-calendar-holidays-initially nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10052 (timestr (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10053 (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") def))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10054 (prompt (concat (if prompt (concat prompt " ") "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10055 (format "Date+time [%s]: " timestr)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10056 ans (org-ans0 "") org-ans1 org-ans2 final)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10057
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10058 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10059 (from-string (setq ans from-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10060 (org-read-date-popup-calendar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10061 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10062 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10063 (calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10064 (calendar-forward-day (- (time-to-days def)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10065 (calendar-absolute-from-gregorian
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10066 (calendar-current-date))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10067 (org-eval-in-calendar nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10068 (let* ((old-map (current-local-map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10069 (map (copy-keymap calendar-mode-map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10070 (minibuffer-local-map (copy-keymap minibuffer-local-map)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10071 (org-defkey map (kbd "RET") 'org-calendar-select)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10072 (org-defkey map (if (featurep 'xemacs) [button1] [mouse-1])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10073 'org-calendar-select-mouse)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10074 (org-defkey map (if (featurep 'xemacs) [button2] [mouse-2])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10075 'org-calendar-select-mouse)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10076 (org-defkey minibuffer-local-map [(meta shift left)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10077 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10078 (org-eval-in-calendar '(calendar-backward-month 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10079 (org-defkey minibuffer-local-map [(meta shift right)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10080 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10081 (org-eval-in-calendar '(calendar-forward-month 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10082 (org-defkey minibuffer-local-map [(meta shift up)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10083 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10084 (org-eval-in-calendar '(calendar-backward-year 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10085 (org-defkey minibuffer-local-map [(meta shift down)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10086 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10087 (org-eval-in-calendar '(calendar-forward-year 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10088 (org-defkey minibuffer-local-map [(shift up)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10089 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10090 (org-eval-in-calendar '(calendar-backward-week 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10091 (org-defkey minibuffer-local-map [(shift down)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10092 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10093 (org-eval-in-calendar '(calendar-forward-week 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10094 (org-defkey minibuffer-local-map [(shift left)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10095 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10096 (org-eval-in-calendar '(calendar-backward-day 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10097 (org-defkey minibuffer-local-map [(shift right)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10098 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10099 (org-eval-in-calendar '(calendar-forward-day 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10100 (org-defkey minibuffer-local-map ">"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10101 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10102 (org-eval-in-calendar '(scroll-calendar-left 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10103 (org-defkey minibuffer-local-map "<"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10104 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10105 (org-eval-in-calendar '(scroll-calendar-right 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10106 (unwind-protect
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10107 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10108 (use-local-map map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10109 (add-hook 'post-command-hook 'org-read-date-display)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10110 (setq org-ans0 (read-string prompt default-input nil nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10111 ;; org-ans0: from prompt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10112 ;; org-ans1: from mouse click
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10113 ;; org-ans2: from calendar motion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10114 (setq ans (concat org-ans0 " " (or org-ans1 org-ans2))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10115 (remove-hook 'post-command-hook 'org-read-date-display)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10116 (use-local-map old-map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10117 (when org-read-date-overlay
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10118 (org-delete-overlay org-read-date-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10119 (setq org-read-date-overlay nil)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10120
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10121 (t ; Naked prompt only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10122 (unwind-protect
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10123 (setq ans (read-string prompt default-input nil timestr))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10124 (when org-read-date-overlay
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10125 (org-delete-overlay org-read-date-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10126 (setq org-read-date-overlay nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10127
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10128 (setq final (org-read-date-analyze ans def defdecode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10129
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10130 (if to-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10131 (apply 'encode-time final)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10132 (if (and (boundp 'org-time-was-given) org-time-was-given)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10133 (format "%04d-%02d-%02d %02d:%02d"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10134 (nth 5 final) (nth 4 final) (nth 3 final)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10135 (nth 2 final) (nth 1 final))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10136 (format "%04d-%02d-%02d" (nth 5 final) (nth 4 final) (nth 3 final))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10137 (defvar def)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10138 (defvar defdecode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10139 (defvar with-time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10140 (defun org-read-date-display ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10141 "Display the currrent date prompt interpretation in the minibuffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10142 (when org-read-date-display-live
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10143 (when org-read-date-overlay
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10144 (org-delete-overlay org-read-date-overlay))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10145 (let ((p (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10146 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10147 (while (not (equal (buffer-substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10148 (max (point-min) (- (point) 4)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10149 " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10150 (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10151 (goto-char p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10152 (let* ((ans (concat (buffer-substring (point-at-bol) (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10153 " " (or org-ans1 org-ans2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10154 (org-end-time-was-given nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10155 (f (org-read-date-analyze ans def defdecode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10156 (fmts (if org-dcst
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10157 org-time-stamp-custom-formats
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10158 org-time-stamp-formats))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10159 (fmt (if (or with-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10160 (and (boundp 'org-time-was-given) org-time-was-given))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10161 (cdr fmts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10162 (car fmts)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10163 (txt (concat "=> " (format-time-string fmt (apply 'encode-time f)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10164 (when (and org-end-time-was-given
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10165 (string-match org-plain-time-of-day-regexp txt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10166 (setq txt (concat (substring txt 0 (match-end 0)) "-"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10167 org-end-time-was-given
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10168 (substring txt (match-end 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10169 (setq org-read-date-overlay
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10170 (make-overlay (1- (point-at-eol)) (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10171 (org-overlay-display org-read-date-overlay txt 'secondary-selection))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10172
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10173 (defun org-read-date-analyze (ans def defdecode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10174 "Analyze the combined answer of the date prompt."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10175 ;; FIXME: cleanup and comment
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10176 (let (delta deltan deltaw deltadef year month day
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10177 hour minute second wday pm h2 m2 tl wday1
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10178 iso-year iso-weekday iso-week iso-year iso-date)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10179
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10180 (when (setq delta (org-read-date-get-relative ans (current-time) def))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10181 (setq ans (replace-match "" t t ans)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10182 deltan (car delta)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10183 deltaw (nth 1 delta)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10184 deltadef (nth 2 delta)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10185
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10186 ;; Check if there is an iso week date in there
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10187 ;; If yes, sore the info and ostpone interpreting it until the rest
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10188 ;; of the parsing is done
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10189 (when (string-match "\\<\\(?:\\([0-9]+\\)-\\)?[wW]\\([0-9]\\{1,2\\}\\)\\(?:-\\([0-6]\\)\\)?\\([ \t]\\|$\\)" ans)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10190 (setq iso-year (if (match-end 1) (org-small-year-to-year (string-to-number (match-string 1 ans))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10191 iso-weekday (if (match-end 3) (string-to-number (match-string 3 ans)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10192 iso-week (string-to-number (match-string 2 ans)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10193 (setq ans (replace-match "" t t ans)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10194
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10195 ;; Help matching ISO dates with single digit month ot day, like 2006-8-11.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10196 (when (string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10197 "^ *\\(\\([0-9]+\\)-\\)?\\([0-1]?[0-9]\\)-\\([0-3]?[0-9]\\)\\([^-0-9]\\|$\\)" ans)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10198 (setq year (if (match-end 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10199 (string-to-number (match-string 2 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10200 (string-to-number (format-time-string "%Y")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10201 month (string-to-number (match-string 3 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10202 day (string-to-number (match-string 4 ans)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10203 (if (< year 100) (setq year (+ 2000 year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10204 (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10205 t nil ans)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10206 ;; Help matching am/pm times, because `parse-time-string' does not do that.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10207 ;; If there is a time with am/pm, and *no* time without it, we convert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10208 ;; so that matching will be successful.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10209 (loop for i from 1 to 2 do ; twice, for end time as well
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10210 (when (and (not (string-match "\\(\\`\\|[^+]\\)[012]?[0-9]:[0-9][0-9]\\([ \t\n]\\|$\\)" ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10211 (string-match "\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\(am\\|AM\\|pm\\|PM\\)\\>" ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10212 (setq hour (string-to-number (match-string 1 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10213 minute (if (match-end 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10214 (string-to-number (match-string 3 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10215 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10216 pm (equal ?p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10217 (string-to-char (downcase (match-string 4 ans)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10218 (if (and (= hour 12) (not pm))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10219 (setq hour 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10220 (if (and pm (< hour 12)) (setq hour (+ 12 hour))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10221 (setq ans (replace-match (format "%02d:%02d" hour minute)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10222 t t ans))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10223
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10224 ;; Check if a time range is given as a duration
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10225 (when (string-match "\\([012]?[0-9]\\):\\([0-6][0-9]\\)\\+\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?" ans)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10226 (setq hour (string-to-number (match-string 1 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10227 h2 (+ hour (string-to-number (match-string 3 ans)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10228 minute (string-to-number (match-string 2 ans))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10229 m2 (+ minute (if (match-end 5) (string-to-number
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10230 (match-string 5 ans))0)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10231 (if (>= m2 60) (setq h2 (1+ h2) m2 (- m2 60)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10232 (setq ans (replace-match (format "%02d:%02d-%02d:%02d" hour minute h2 m2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10233 t t ans)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10234
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10235 ;; Check if there is a time range
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10236 (when (boundp 'org-end-time-was-given)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10237 (setq org-time-was-given nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10238 (when (and (string-match org-plain-time-of-day-regexp ans)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10239 (match-end 8))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10240 (setq org-end-time-was-given (match-string 8 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10241 (setq ans (concat (substring ans 0 (match-beginning 7))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10242 (substring ans (match-end 7))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10243
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10244 (setq tl (parse-time-string ans)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10245 day (or (nth 3 tl) (nth 3 defdecode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10246 month (or (nth 4 tl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10247 (if (and org-read-date-prefer-future
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10248 (nth 3 tl) (< (nth 3 tl) (nth 3 defdecode)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10249 (1+ (nth 4 defdecode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10250 (nth 4 defdecode)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10251 year (or (nth 5 tl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10252 (if (and org-read-date-prefer-future
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10253 (nth 4 tl) (< (nth 4 tl) (nth 4 defdecode)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10254 (1+ (nth 5 defdecode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10255 (nth 5 defdecode)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10256 hour (or (nth 2 tl) (nth 2 defdecode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10257 minute (or (nth 1 tl) (nth 1 defdecode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10258 second (or (nth 0 tl) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10259 wday (nth 6 tl))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10260
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10261 ;; Special date definitions below
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10262 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10263 (iso-week
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10264 ;; There was an iso week
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10265 (setq year (or iso-year year)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10266 day (or iso-weekday wday 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10267 wday nil ; to make sure that the trigger below does not match
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10268 iso-date (calendar-gregorian-from-absolute
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10269 (calendar-absolute-from-iso
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10270 (list iso-week day year))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10271 ; FIXME: Should we also push ISO weeks into the future?
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10272 ; (when (and org-read-date-prefer-future
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10273 ; (not iso-year)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10274 ; (< (calendar-absolute-from-gregorian iso-date)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10275 ; (time-to-days (current-time))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10276 ; (setq year (1+ year)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10277 ; iso-date (calendar-gregorian-from-absolute
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10278 ; (calendar-absolute-from-iso
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10279 ; (list iso-week day year)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10280 (setq month (car iso-date)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10281 year (nth 2 iso-date)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10282 day (nth 1 iso-date)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10283 (deltan
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10284 (unless deltadef
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10285 (let ((now (decode-time (current-time))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10286 (setq day (nth 3 now) month (nth 4 now) year (nth 5 now))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10287 (cond ((member deltaw '("d" "")) (setq day (+ day deltan)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10288 ((equal deltaw "w") (setq day (+ day (* 7 deltan))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10289 ((equal deltaw "m") (setq month (+ month deltan)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10290 ((equal deltaw "y") (setq year (+ year deltan)))))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10291 ((and wday (not (nth 3 tl)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10292 ;; Weekday was given, but no day, so pick that day in the week
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10293 ;; on or after the derived date.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10294 (setq wday1 (nth 6 (decode-time (encode-time 0 0 0 day month year))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10295 (unless (equal wday wday1)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10296 (setq day (+ day (% (- wday wday1 -7) 7))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10297 (if (and (boundp 'org-time-was-given)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10298 (nth 2 tl))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10299 (setq org-time-was-given t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10300 (if (< year 100) (setq year (+ 2000 year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10301 (if (< year 1970) (setq year (nth 5 defdecode))) ; not representable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10302 (list second minute hour day month year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10303
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10304 (defvar parse-time-weekdays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10305
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10306 (defun org-read-date-get-relative (s today default)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10307 "Check string S for special relative date string.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10308 TODAY and DEFAULT are internal times, for today and for a default.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10309 Return shift list (N what def-flag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10310 WHAT is \"d\", \"w\", \"m\", or \"y\" for day, week, month, year.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10311 N is the number of WHATs to shift.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10312 DEF-FLAG is t when a double ++ or -- indicates shift relative to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10313 the DEFAULT date rather than TODAY."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10314 (when (string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10315 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10316 "\\`[ \t]*\\([-+]\\{1,2\\}\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10317 "\\([0-9]+\\)?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10318 "\\([dwmy]\\|\\(" (mapconcat 'car parse-time-weekdays "\\|") "\\)\\)?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10319 "\\([ \t]\\|$\\)") s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10320 (let* ((dir (if (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10321 (string-to-char (substring (match-string 1 s) -1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10322 ?+))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10323 (rel (and (match-end 1) (= 2 (- (match-end 1) (match-beginning 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10324 (n (if (match-end 2) (string-to-number (match-string 2 s)) 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10325 (what (if (match-end 3) (match-string 3 s) "d"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10326 (wday1 (cdr (assoc (downcase what) parse-time-weekdays)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10327 (date (if rel default today))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10328 (wday (nth 6 (decode-time date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10329 delta)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10330 (if wday1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10331 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10332 (setq delta (mod (+ 7 (- wday1 wday)) 7))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10333 (if (= dir ?-) (setq delta (- delta 7)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10334 (if (> n 1) (setq delta (+ delta (* (1- n) (if (= dir ?-) -7 7)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10335 (list delta "d" rel))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10336 (list (* n (if (= dir ?-) -1 1)) what rel)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10337
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10338 (defun org-eval-in-calendar (form &optional keepdate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10339 "Eval FORM in the calendar window and return to current window.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10340 Also, store the cursor date in variable org-ans2."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10341 (let ((sw (selected-window)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10342 (select-window (get-buffer-window "*Calendar*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10343 (eval form)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10344 (when (and (not keepdate) (calendar-cursor-to-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10345 (let* ((date (calendar-cursor-to-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10346 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10347 (setq org-ans2 (format-time-string "%Y-%m-%d" time))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10348 (org-move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10349 (select-window sw)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10350
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10351 ; ;; Update the prompt to show new default date
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10352 ; (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10353 ; (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10354 ; (when (and org-ans2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10355 ; (re-search-forward "\\[[-0-9]+\\]" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10356 ; (get-text-property (match-end 0) 'field))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10357 ; (let ((inhibit-read-only t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10358 ; (replace-match (concat "[" org-ans2 "]") t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10359 ; (add-text-properties (point-min) (1+ (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10360 ; (text-properties-at (1+ (point-min)))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10361
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10362 (defun org-calendar-select ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10363 "Return to `org-read-date' with the date currently selected.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10364 This is used by `org-read-date' in a temporary keymap for the calendar buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10365 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10366 (when (calendar-cursor-to-date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10367 (let* ((date (calendar-cursor-to-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10368 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10369 (setq org-ans1 (format-time-string "%Y-%m-%d" time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10370 (if (active-minibuffer-window) (exit-minibuffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10371
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10372 (defun org-insert-time-stamp (time &optional with-hm inactive pre post extra)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10373 "Insert a date stamp for the date given by the internal TIME.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10374 WITH-HM means, use the stamp format that includes the time of the day.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10375 INACTIVE means use square brackets instead of angular ones, so that the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10376 stamp will not contribute to the agenda.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10377 PRE and POST are optional strings to be inserted before and after the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10378 stamp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10379 The command returns the inserted time stamp."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10380 (let ((fmt (funcall (if with-hm 'cdr 'car) org-time-stamp-formats))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10381 stamp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10382 (if inactive (setq fmt (concat "[" (substring fmt 1 -1) "]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10383 (insert-before-markers (or pre ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10384 (insert-before-markers (setq stamp (format-time-string fmt time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10385 (when (listp extra)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10386 (setq extra (car extra))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10387 (if (and (stringp extra)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10388 (string-match "\\([0-9]+\\):\\([0-9]+\\)" extra))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10389 (setq extra (format "-%02d:%02d"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10390 (string-to-number (match-string 1 extra))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10391 (string-to-number (match-string 2 extra))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10392 (setq extra nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10393 (when extra
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10394 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10395 (insert-before-markers extra)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10396 (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10397 (insert-before-markers (or post ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10398 stamp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10399
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10400 (defun org-toggle-time-stamp-overlays ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10401 "Toggle the use of custom time stamp formats."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10402 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10403 (setq org-display-custom-times (not org-display-custom-times))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10404 (unless org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10405 (let ((p (point-min)) (bmp (buffer-modified-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10406 (while (setq p (next-single-property-change p 'display))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10407 (if (and (get-text-property p 'display)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10408 (eq (get-text-property p 'face) 'org-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10409 (remove-text-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10410 p (setq p (next-single-property-change p 'display))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10411 '(display t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10412 (set-buffer-modified-p bmp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10413 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10414 (remove-text-properties (point-min) (point-max) '(end-glyph t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10415 (org-restart-font-lock)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10416 (setq org-table-may-need-update t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10417 (if org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10418 (message "Time stamps are overlayed with custom format")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10419 (message "Time stamp overlays removed")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10420
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10421 (defun org-display-custom-time (beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10422 "Overlay modified time stamp format over timestamp between BED and END."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10423 (let* ((ts (buffer-substring beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10424 t1 w1 with-hm tf time str w2 (off 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10425 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10426 (setq t1 (org-parse-time-string ts t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10427 (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\( [.+]?\\+[0-9]+[dwmy]\\)?\\'" ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10428 (setq off (- (match-end 0) (match-beginning 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10429 (setq end (- end off))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10430 (setq w1 (- end beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10431 with-hm (and (nth 1 t1) (nth 2 t1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10432 tf (funcall (if with-hm 'cdr 'car) org-time-stamp-custom-formats)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10433 time (org-fix-decoded-time t1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10434 str (org-add-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10435 (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10436 (substring tf 1 -1) (apply 'encode-time time))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10437 nil 'mouse-face 'highlight)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10438 w2 (length str))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10439 (if (not (= w2 w1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10440 (add-text-properties (1+ beg) (+ 2 beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10441 (list 'org-dwidth t 'org-dwidth-n (- w1 w2))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10442 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10443 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10444 (put-text-property beg end 'invisible t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10445 (put-text-property beg end 'end-glyph (make-glyph str)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10446 (put-text-property beg end 'display str))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10447
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10448 (defun org-translate-time (string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10449 "Translate all timestamps in STRING to custom format.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10450 But do this only if the variable `org-display-custom-times' is set."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10451 (when org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10452 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10453 (let* ((start 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10454 (re org-ts-regexp-both)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10455 t1 with-hm inactive tf time str beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10456 (while (setq start (string-match re string start))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10457 (setq beg (match-beginning 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10458 end (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10459 t1 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10460 (org-parse-time-string (substring string beg end) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10461 with-hm (and (nth 1 t1) (nth 2 t1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10462 inactive (equal (substring string beg (1+ beg)) "[")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10463 tf (funcall (if with-hm 'cdr 'car)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10464 org-time-stamp-custom-formats)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10465 time (org-fix-decoded-time t1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10466 str (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10467 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10468 (if inactive "[" "<") (substring tf 1 -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10469 (if inactive "]" ">"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10470 (apply 'encode-time time))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10471 string (replace-match str t t string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10472 start (+ start (length str)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10473 string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10474
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10475 (defun org-fix-decoded-time (time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10476 "Set 0 instead of nil for the first 6 elements of time.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10477 Don't touch the rest."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10478 (let ((n 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10479 (mapcar (lambda (x) (if (< (setq n (1+ n)) 7) (or x 0) x)) time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10480
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10481 (defun org-days-to-time (timestamp-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10482 "Difference between TIMESTAMP-STRING and now in days."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10483 (- (time-to-days (org-time-string-to-time timestamp-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10484 (time-to-days (current-time))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10485
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10486 (defun org-deadline-close (timestamp-string &optional ndays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10487 "Is the time in TIMESTAMP-STRING close to the current date?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10488 (setq ndays (or ndays (org-get-wdays timestamp-string)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10489 (and (< (org-days-to-time timestamp-string) ndays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10490 (not (org-entry-is-done-p))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10491
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10492 (defun org-get-wdays (ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10493 "Get the deadline lead time appropriate for timestring TS."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10494 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10495 ((<= org-deadline-warning-days 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10496 ;; 0 or negative, enforce this value no matter what
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10497 (- org-deadline-warning-days))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10498 ((string-match "-\\([0-9]+\\)\\([dwmy]\\)\\(\\'\\|>\\)" ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10499 ;; lead time is specified.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10500 (floor (* (string-to-number (match-string 1 ts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10501 (cdr (assoc (match-string 2 ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10502 '(("d" . 1) ("w" . 7)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10503 ("m" . 30.4) ("y" . 365.25)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10504 ;; go for the default.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10505 (t org-deadline-warning-days)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10506
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10507 (defun org-calendar-select-mouse (ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10508 "Return to `org-read-date' with the date currently selected.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10509 This is used by `org-read-date' in a temporary keymap for the calendar buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10510 (interactive "e")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10511 (mouse-set-point ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10512 (when (calendar-cursor-to-date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10513 (let* ((date (calendar-cursor-to-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10514 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10515 (setq org-ans1 (format-time-string "%Y-%m-%d" time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10516 (if (active-minibuffer-window) (exit-minibuffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10517
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10518 (defun org-check-deadlines (ndays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10519 "Check if there are any deadlines due or past due.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10520 A deadline is considered due if it happens within `org-deadline-warning-days'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10521 days from today's date. If the deadline appears in an entry marked DONE,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10522 it is not shown. The prefix arg NDAYS can be used to test that many
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10523 days. If the prefix is a raw \\[universal-argument] prefix, all deadlines are shown."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10524 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10525 (let* ((org-warn-days
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10526 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10527 ((equal ndays '(4)) 100000)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10528 (ndays (prefix-numeric-value ndays))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10529 (t (abs org-deadline-warning-days))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10530 (case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10531 (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10532 (callback
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10533 (lambda () (org-deadline-close (match-string 1) org-warn-days))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10534
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10535 (message "%d deadlines past-due or due within %d days"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10536 (org-occur regexp nil callback)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10537 org-warn-days)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10538
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10539 (defun org-check-before-date (date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10540 "Check if there are deadlines or scheduled entries before DATE."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10541 (interactive (list (org-read-date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10542 (let ((case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10543 (regexp (concat "\\<\\(" org-deadline-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10544 "\\|" org-scheduled-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10545 "\\) *<\\([^>]+\\)>"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10546 (callback
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10547 (lambda () (time-less-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10548 (org-time-string-to-time (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10549 (org-time-string-to-time date)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10550 (message "%d entries before %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10551 (org-occur regexp nil callback) date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10552
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10553 (defun org-evaluate-time-range (&optional to-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10554 "Evaluate a time range by computing the difference between start and end.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10555 Normally the result is just printed in the echo area, but with prefix arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10556 TO-BUFFER, the result is inserted just after the date stamp into the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10557 If the time range is actually in a table, the result is inserted into the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10558 next column.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10559 For time difference computation, a year is assumed to be exactly 365
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10560 days in order to avoid rounding problems."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10561 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10562 (or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10563 (org-clock-update-time-maybe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10564 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10565 (unless (org-at-date-range-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10566 (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10567 (re-search-forward org-tr-regexp-both (point-at-eol) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10568 (if (not (org-at-date-range-p t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10569 (error "Not at a time-stamp range, and none found in current line")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10570 (let* ((ts1 (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10571 (ts2 (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10572 (havetime (or (> (length ts1) 15) (> (length ts2) 15)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10573 (match-end (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10574 (time1 (org-time-string-to-time ts1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10575 (time2 (org-time-string-to-time ts2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10576 (t1 (time-to-seconds time1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10577 (t2 (time-to-seconds time2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10578 (diff (abs (- t2 t1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10579 (negative (< (- t2 t1) 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10580 ;; (ys (floor (* 365 24 60 60)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10581 (ds (* 24 60 60))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10582 (hs (* 60 60))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10583 (fy "%dy %dd %02d:%02d")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10584 (fy1 "%dy %dd")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10585 (fd "%dd %02d:%02d")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10586 (fd1 "%dd")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10587 (fh "%02d:%02d")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10588 y d h m align)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10589 (if havetime
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10590 (setq ; y (floor (/ diff ys)) diff (mod diff ys)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10591 y 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10592 d (floor (/ diff ds)) diff (mod diff ds)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10593 h (floor (/ diff hs)) diff (mod diff hs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10594 m (floor (/ diff 60)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10595 (setq ; y (floor (/ diff ys)) diff (mod diff ys)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10596 y 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10597 d (floor (+ (/ diff ds) 0.5))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10598 h 0 m 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10599 (if (not to-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10600 (message "%s" (org-make-tdiff-string y d h m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10601 (if (org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10602 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10603 (goto-char match-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10604 (setq align t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10605 (and (looking-at " *|") (goto-char (match-end 0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10606 (goto-char match-end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10607 (if (looking-at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10608 "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10609 (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10610 (if negative (insert " -"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10611 (if (> y 0) (insert " " (format (if havetime fy fy1) y d h m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10612 (if (> d 0) (insert " " (format (if havetime fd fd1) d h m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10613 (insert " " (format fh h m))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10614 (if align (org-table-align))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10615 (message "Time difference inserted")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10616
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10617 (defun org-make-tdiff-string (y d h m)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10618 (let ((fmt "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10619 (l nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10620 (if (> y 0) (setq fmt (concat fmt "%d year" (if (> y 1) "s" "") " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10621 l (push y l)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10622 (if (> d 0) (setq fmt (concat fmt "%d day" (if (> d 1) "s" "") " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10623 l (push d l)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10624 (if (> h 0) (setq fmt (concat fmt "%d hour" (if (> h 1) "s" "") " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10625 l (push h l)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10626 (if (> m 0) (setq fmt (concat fmt "%d minute" (if (> m 1) "s" "") " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10627 l (push m l)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10628 (apply 'format fmt (nreverse l))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10629
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10630 (defun org-time-string-to-time (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10631 (apply 'encode-time (org-parse-time-string s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10632
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10633 (defun org-time-string-to-absolute (s &optional daynr prefer show-all)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10634 "Convert a time stamp to an absolute day number.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10635 If there is a specifyer for a cyclic time stamp, get the closest date to
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10636 DAYNR.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10637 PREFER and SHOW_ALL are passed through to `org-closest-date'."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10638 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10639 ((and daynr (string-match "\\`%%\\((.*)\\)" s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10640 (if (org-diary-sexp-entry (match-string 1 s) "" date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10641 daynr
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10642 (+ daynr 1000)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10643 ((and daynr (string-match "\\+[0-9]+[dwmy]" s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10644 (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10645 (time-to-days (current-time))) (match-string 0 s)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10646 prefer show-all))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10647 (t (time-to-days (apply 'encode-time (org-parse-time-string s))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10648
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10649 (defun org-days-to-iso-week (days)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10650 "Return the iso week number."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10651 (require 'cal-iso)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10652 (car (calendar-iso-from-absolute days)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10653
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10654 (defun org-small-year-to-year (year)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10655 "Convert 2-digit years into 4-digit years.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10656 38-99 are mapped into 1938-1999. 1-37 are mapped into 2001-2007.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10657 The year 2000 cannot be abbreviated. Any year lager than 99
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10658 is retrned unchanged."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10659 (if (< year 38)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10660 (setq year (+ 2000 year))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10661 (if (< year 100)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10662 (setq year (+ 1900 year))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10663 year)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10664
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10665 (defun org-time-from-absolute (d)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10666 "Return the time corresponding to date D.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10667 D may be an absolute day number, or a calendar-type list (month day year)."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10668 (if (numberp d) (setq d (calendar-gregorian-from-absolute d)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10669 (encode-time 0 0 0 (nth 1 d) (car d) (nth 2 d)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10670
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10671 (defun org-calendar-holiday ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10672 "List of holidays, for Diary display in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10673 (require 'holidays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10674 (let ((hl (funcall
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10675 (if (fboundp 'calendar-check-holidays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10676 'calendar-check-holidays 'check-calendar-holidays) date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10677 (if hl (mapconcat 'identity hl "; "))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10678
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10679 (defun org-diary-sexp-entry (sexp entry date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10680 "Process a SEXP diary ENTRY for DATE."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10681 (require 'diary-lib)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10682 (let ((result (if calendar-debug-sexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10683 (let ((stack-trace-on-error t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10684 (eval (car (read-from-string sexp))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10685 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10686 (eval (car (read-from-string sexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10687 (error
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10688 (beep)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10689 (message "Bad sexp at line %d in %s: %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10690 (org-current-line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10691 (buffer-file-name) sexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10692 (sleep-for 2))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10693 (cond ((stringp result) result)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10694 ((and (consp result)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10695 (stringp (cdr result))) (cdr result))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10696 (result entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10697 (t nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10698
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10699 (defun org-diary-to-ical-string (frombuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10700 "Get iCalendar entries from diary entries in buffer FROMBUF.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10701 This uses the icalendar.el library."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10702 (let* ((tmpdir (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10703 (temp-directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10704 temporary-file-directory))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10705 (tmpfile (make-temp-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10706 (expand-file-name "orgics" tmpdir)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10707 buf rtn b e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10708 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10709 (set-buffer frombuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10710 (icalendar-export-region (point-min) (point-max) tmpfile)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10711 (setq buf (find-buffer-visiting tmpfile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10712 (set-buffer buf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10713 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10714 (if (re-search-forward "^BEGIN:VEVENT" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10715 (setq b (match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10716 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10717 (if (re-search-backward "^END:VEVENT" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10718 (setq e (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10719 (setq rtn (if (and b e) (concat (buffer-substring b e) "\n") "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10720 (kill-buffer buf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10721 (kill-buffer frombuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10722 (delete-file tmpfile)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10723 rtn))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10724
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10725 (defun org-closest-date (start current change prefer show-all)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10726 "Find the date closest to CURRENT that is consistent with START and CHANGE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10727 When PREFER is `past' return a date that is either CURRENT or past.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10728 When PREFER is `future', return a date that is either CURRENT or future.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10729 When SHOW-ALL is nil, only return the current occurence of a time stamp."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10730 ;; Make the proper lists from the dates
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10731 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10732 (let ((a1 '(("d" . day) ("w" . week) ("m" . month) ("y" . year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10733 dn dw sday cday n1 n2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10734 d m y y1 y2 date1 date2 nmonths nm ny m2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10735
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10736 (setq start (org-date-to-gregorian start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10737 current (org-date-to-gregorian
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10738 (if show-all
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10739 current
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10740 (time-to-days (current-time))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10741 sday (calendar-absolute-from-gregorian start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10742 cday (calendar-absolute-from-gregorian current))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10743
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10744 (if (<= cday sday) (throw 'exit sday))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10745
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10746 (if (string-match "\\(\\+[0-9]+\\)\\([dwmy]\\)" change)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10747 (setq dn (string-to-number (match-string 1 change))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10748 dw (cdr (assoc (match-string 2 change) a1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10749 (error "Invalid change specifyer: %s" change))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10750 (if (eq dw 'week) (setq dw 'day dn (* 7 dn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10751 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10752 ((eq dw 'day)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10753 (setq n1 (+ sday (* dn (floor (/ (- cday sday) dn))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10754 n2 (+ n1 dn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10755 ((eq dw 'year)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10756 (setq d (nth 1 start) m (car start) y1 (nth 2 start) y2 (nth 2 current))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10757 (setq y1 (+ (* (floor (/ (- y2 y1) dn)) dn) y1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10758 (setq date1 (list m d y1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10759 n1 (calendar-absolute-from-gregorian date1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10760 date2 (list m d (+ y1 (* (if (< n1 cday) 1 -1) dn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10761 n2 (calendar-absolute-from-gregorian date2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10762 ((eq dw 'month)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10763 ;; approx number of month between the tow dates
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10764 (setq nmonths (floor (/ (- cday sday) 30.436875)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10765 ;; How often does dn fit in there?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10766 (setq d (nth 1 start) m (car start) y (nth 2 start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10767 nm (* dn (max 0 (1- (floor (/ nmonths dn)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10768 m (+ m nm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10769 ny (floor (/ m 12))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10770 y (+ y ny)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10771 m (- m (* ny 12)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10772 (while (> m 12) (setq m (- m 12) y (1+ y)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10773 (setq n1 (calendar-absolute-from-gregorian (list m d y)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10774 (setq m2 (+ m dn) y2 y)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10775 (if (> m2 12) (setq y2 (1+ y2) m2 (- m2 12)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10776 (setq n2 (calendar-absolute-from-gregorian (list m2 d y2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10777 (while (< n2 cday)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10778 (setq n1 n2 m m2 y y2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10779 (setq m2 (+ m dn) y2 y)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10780 (if (> m2 12) (setq y2 (1+ y2) m2 (- m2 12)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10781 (setq n2 (calendar-absolute-from-gregorian (list m2 d y2))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10782
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10783 (if show-all
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10784 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10785 ((eq prefer 'past) n1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10786 ((eq prefer 'future) (if (= cday n1) n1 n2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10787 (t (if (> (abs (- cday n1)) (abs (- cday n2))) n2 n1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10788 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10789 ((eq prefer 'past) n1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10790 ((eq prefer 'future) (if (= cday n1) n1 n2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10791 (t (if (= cday n1) n1 n2)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10792
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10793 (defun org-date-to-gregorian (date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10794 "Turn any specification of DATE into a gregorian date for the calendar."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10795 (cond ((integerp date) (calendar-gregorian-from-absolute date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10796 ((and (listp date) (= (length date) 3)) date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10797 ((stringp date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10798 (setq date (org-parse-time-string date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10799 (list (nth 4 date) (nth 3 date) (nth 5 date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10800 ((listp date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10801 (list (nth 4 date) (nth 3 date) (nth 5 date)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10802
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10803 (defun org-parse-time-string (s &optional nodefault)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10804 "Parse the standard Org-mode time string.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10805 This should be a lot faster than the normal `parse-time-string'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10806 If time is not given, defaults to 0:00. However, with optional NODEFAULT,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10807 hour and minute fields will be nil if not given."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10808 (if (string-match org-ts-regexp0 s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10809 (list 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10810 (if (or (match-beginning 8) (not nodefault))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10811 (string-to-number (or (match-string 8 s) "0")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10812 (if (or (match-beginning 7) (not nodefault))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10813 (string-to-number (or (match-string 7 s) "0")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10814 (string-to-number (match-string 4 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10815 (string-to-number (match-string 3 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10816 (string-to-number (match-string 2 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10817 nil nil nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10818 (make-list 9 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10819
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10820 (defun org-timestamp-up (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10821 "Increase the date item at the cursor by one.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10822 If the cursor is on the year, change the year. If it is on the month or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10823 the day, change that.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10824 With prefix ARG, change by that many units."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10825 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10826 (org-timestamp-change (prefix-numeric-value arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10827
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10828 (defun org-timestamp-down (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10829 "Decrease the date item at the cursor by one.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10830 If the cursor is on the year, change the year. If it is on the month or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10831 the day, change that.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10832 With prefix ARG, change by that many units."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10833 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10834 (org-timestamp-change (- (prefix-numeric-value arg))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10835
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10836 (defun org-timestamp-up-day (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10837 "Increase the date in the time stamp by one day.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10838 With prefix ARG, change that many days."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10839 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10840 (if (and (not (org-at-timestamp-p t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10841 (org-on-heading-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10842 (org-todo 'up)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10843 (org-timestamp-change (prefix-numeric-value arg) 'day)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10844
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10845 (defun org-timestamp-down-day (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10846 "Decrease the date in the time stamp by one day.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10847 With prefix ARG, change that many days."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10848 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10849 (if (and (not (org-at-timestamp-p t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10850 (org-on-heading-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10851 (org-todo 'down)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10852 (org-timestamp-change (- (prefix-numeric-value arg)) 'day)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10853
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10854 (defun org-at-timestamp-p (&optional inactive-ok)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10855 "Determine if the cursor is in or at a timestamp."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10856 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10857 (let* ((tsr (if inactive-ok org-ts-regexp3 org-ts-regexp2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10858 (pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10859 (ans (or (looking-at tsr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10860 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10861 (skip-chars-backward "^[<\n\r\t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10862 (if (> (point) (point-min)) (backward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10863 (and (looking-at tsr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10864 (> (- (match-end 0) pos) -1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10865 (and ans
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10866 (boundp 'org-ts-what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10867 (setq org-ts-what
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10868 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10869 ((= pos (match-beginning 0)) 'bracket)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10870 ((= pos (1- (match-end 0))) 'bracket)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10871 ((org-pos-in-match-range pos 2) 'year)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10872 ((org-pos-in-match-range pos 3) 'month)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10873 ((org-pos-in-match-range pos 7) 'hour)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10874 ((org-pos-in-match-range pos 8) 'minute)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10875 ((or (org-pos-in-match-range pos 4)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10876 (org-pos-in-match-range pos 5)) 'day)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10877 ((and (> pos (or (match-end 8) (match-end 5)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10878 (< pos (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10879 (- pos (or (match-end 8) (match-end 5))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10880 (t 'day))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10881 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10882
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10883 (defun org-toggle-timestamp-type ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10884 "Toggle the type (<active> or [inactive]) of a time stamp."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10885 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10886 (when (org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10887 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10888 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10889 (insert (if (equal (char-after) ?<) "[" "<")) (delete-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10890 (goto-char (1- (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10891 (insert (if (equal (char-after) ?>) "]" ">")) (delete-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10892 (message "Timestamp is now %sactive"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10893 (if (equal (char-before) ?>) "in" ""))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10894
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10895 (defun org-timestamp-change (n &optional what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10896 "Change the date in the time stamp at point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10897 The date will be changed by N times WHAT. WHAT can be `day', `month',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10898 `year', `minute', `second'. If WHAT is not given, the cursor position
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10899 in the timestamp determines what will be changed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10900 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10901 with-hm inactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10902 (dm (max (nth 1 org-time-stamp-rounding-minutes) 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10903 org-ts-what
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10904 extra rem
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10905 ts time time0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10906 (if (not (org-at-timestamp-p t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10907 (error "Not at a timestamp"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10908 (if (and (not what) (eq org-ts-what 'bracket))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10909 (org-toggle-timestamp-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10910 (if (and (not what) (not (eq org-ts-what 'day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10911 org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10912 (get-text-property (point) 'display)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10913 (not (get-text-property (1- (point)) 'display)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10914 (setq org-ts-what 'day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10915 (setq org-ts-what (or what org-ts-what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10916 inactive (= (char-after (match-beginning 0)) ?\[)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10917 ts (match-string 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10918 (replace-match "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10919 (if (string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10920 "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?[-+][0-9]+[dwmy]\\)*\\)[]>]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10921 ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10922 (setq extra (match-string 1 ts)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10923 (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10924 (setq with-hm t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10925 (setq time0 (org-parse-time-string ts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10926 (when (and (eq org-ts-what 'minute)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10927 (eq current-prefix-arg nil))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10928 (setq n (* dm (cond ((> n 0) 1) ((< n 0) -1) (t 0))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10929 (when (not (= 0 (setq rem (% (nth 1 time0) dm))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10930 (setcar (cdr time0) (+ (nth 1 time0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10931 (if (> n 0) (- rem) (- dm rem))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10932 (setq time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10933 (encode-time (or (car time0) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10934 (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10935 (+ (if (eq org-ts-what 'hour) n 0) (nth 2 time0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10936 (+ (if (eq org-ts-what 'day) n 0) (nth 3 time0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10937 (+ (if (eq org-ts-what 'month) n 0) (nth 4 time0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10938 (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10939 (nthcdr 6 time0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10940 (when (integerp org-ts-what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10941 (setq extra (org-modify-ts-extra extra org-ts-what n dm)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10942 (if (eq what 'calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10943 (let ((cal-date (org-get-date-from-calendar)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10944 (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10945 (setcar (nthcdr 3 time0) (nth 1 cal-date)) ; day
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10946 (setcar (nthcdr 5 time0) (nth 2 cal-date)) ; year
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10947 (setcar time0 (or (car time0) 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10948 (setcar (nthcdr 1 time0) (or (nth 1 time0) 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10949 (setcar (nthcdr 2 time0) (or (nth 2 time0) 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10950 (setq time (apply 'encode-time time0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10951 (setq org-last-changed-timestamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10952 (org-insert-time-stamp time with-hm inactive nil nil extra))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10953 (org-clock-update-time-maybe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10954 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10955 ;; Try to recenter the calendar window, if any
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10956 (if (and org-calendar-follow-timestamp-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10957 (get-buffer-window "*Calendar*" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10958 (memq org-ts-what '(day month year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10959 (org-recenter-calendar (time-to-days time))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10960
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10961 (defun org-modify-ts-extra (s pos n dm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10962 "Change the different parts of the lead-time and repeat fields in timestamp."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10963 (let ((idx '(("d" . 0) ("w" . 1) ("m" . 2) ("y" . 3) ("d" . -1) ("y" . 4)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10964 ng h m new rem)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10965 (when (string-match "\\(-\\([012][0-9]\\):\\([0-5][0-9]\\)\\)?\\( +\\+\\([0-9]+\\)\\([dmwy]\\)\\)?\\( +-\\([0-9]+\\)\\([dmwy]\\)\\)?" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10966 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10967 ((or (org-pos-in-match-range pos 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10968 (org-pos-in-match-range pos 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10969 (setq m (string-to-number (match-string 3 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10970 h (string-to-number (match-string 2 s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10971 (if (org-pos-in-match-range pos 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10972 (setq h (+ h n))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10973 (setq n (* dm (org-no-warnings (signum n))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10974 (when (not (= 0 (setq rem (% m dm))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10975 (setq m (+ m (if (> n 0) (- rem) (- dm rem)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10976 (setq m (+ m n)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10977 (if (< m 0) (setq m (+ m 60) h (1- h)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10978 (if (> m 59) (setq m (- m 60) h (1+ h)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10979 (setq h (min 24 (max 0 h)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10980 (setq ng 1 new (format "-%02d:%02d" h m)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10981 ((org-pos-in-match-range pos 6)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10982 (setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10983 ((org-pos-in-match-range pos 5)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10984 (setq ng 5 new (format "%d" (max 1 (+ n (string-to-number (match-string 5 s)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10985
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10986 ((org-pos-in-match-range pos 9)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10987 (setq ng 9 new (car (rassoc (+ n (cdr (assoc (match-string 9 s) idx))) idx))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10988 ((org-pos-in-match-range pos 8)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10989 (setq ng 8 new (format "%d" (max 0 (+ n (string-to-number (match-string 8 s))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10990
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10991 (when ng
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10992 (setq s (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10993 (substring s 0 (match-beginning ng))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10994 new
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10995 (substring s (match-end ng))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10996 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10997
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10998 (defun org-recenter-calendar (date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10999 "If the calendar is visible, recenter it to DATE."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11000 (let* ((win (selected-window))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11001 (cwin (get-buffer-window "*Calendar*" t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11002 (calendar-move-hook nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11003 (when cwin
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11004 (select-window cwin)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11005 (calendar-goto-date (if (listp date) date
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11006 (calendar-gregorian-from-absolute date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11007 (select-window win))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11008
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11009 (defun org-goto-calendar (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11010 "Go to the Emacs calendar at the current date.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11011 If there is a time stamp in the current line, go to that date.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11012 A prefix ARG can be used to force the current date."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11013 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11014 (let ((tsr org-ts-regexp) diff
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11015 (calendar-move-hook nil)
93810
ba0874919ac4 (org-agenda-format-date-aligned, org-agenda-execute-calendar-command):
Glenn Morris <rgm@gnu.org>
parents: 93141
diff changeset
11016 (calendar-view-holidays-initially-flag nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11017 (view-calendar-holidays-initially nil)
93810
ba0874919ac4 (org-agenda-format-date-aligned, org-agenda-execute-calendar-command):
Glenn Morris <rgm@gnu.org>
parents: 93141
diff changeset
11018 (calendar-view-diary-initially-flag nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11019 (view-diary-entries-initially nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11020 (if (or (org-at-timestamp-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11021 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11022 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11023 (looking-at (concat ".*" tsr))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11024 (let ((d1 (time-to-days (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11025 (d2 (time-to-days
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11026 (org-time-string-to-time (match-string 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11027 (setq diff (- d2 d1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11028 (calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11029 (calendar-goto-today)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11030 (if (and diff (not arg)) (calendar-forward-day diff))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11031
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11032 (defun org-get-date-from-calendar ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11033 "Return a list (month day year) of date at point in calendar."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11034 (with-current-buffer "*Calendar*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11035 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11036 (calendar-cursor-to-date))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11037
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11038 (defun org-date-from-calendar ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11039 "Insert time stamp corresponding to cursor date in *Calendar* buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11040 If there is already a time stamp at the cursor position, update it."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11041 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11042 (if (org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11043 (org-timestamp-change 0 'calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11044 (let ((cal-date (org-get-date-from-calendar)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11045 (org-insert-time-stamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11046 (encode-time 0 0 0 (nth 1 cal-date) (car cal-date) (nth 2 cal-date))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11047
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11048 (defun org-minutes-to-hh:mm-string (m)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11049 "Compute H:MM from a number of minutes."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11050 (let ((h (/ m 60)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11051 (setq m (- m (* 60 h)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11052 (format "%d:%02d" h m)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11053
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11054 (defun org-hh:mm-string-to-minutes (s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11055 "Convert a string H:MM to a number of minutes."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11056 (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11057 (+ (* (string-to-number (match-string 1 s)) 60)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11058 (string-to-number (match-string 2 s)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11059 0))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11060
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11061 ;;;; Agenda files
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11062
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11063 ;;;###autoload
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11064 (defun org-iswitchb (&optional arg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11065 "Use `iswitchb-read-buffer' to prompt for an Org buffer to switch to.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11066 With a prefix argument, restrict available to files.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11067 With two prefix arguments, restrict available buffers to agenda files.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11068
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11069 Due to some yet unresolved reason, global function
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11070 `iswitchb-mode' needs to be active for this function to work."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11071 (interactive "P")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11072 (require 'iswitchb)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11073 (let ((enabled iswitchb-mode) blist)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11074 (or enabled (iswitchb-mode 1))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11075 (setq blist (cond ((equal arg '(4)) (org-buffer-list 'files))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11076 ((equal arg '(16)) (org-buffer-list 'agenda))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11077 (t (org-buffer-list))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11078 (unwind-protect
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11079 (let ((iswitchb-make-buflist-hook
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11080 (lambda ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11081 (setq iswitchb-temp-buflist
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11082 (mapcar 'buffer-name blist)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11083 (switch-to-buffer
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11084 (iswitchb-read-buffer
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11085 "Switch-to: " nil t))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11086 (or enabled (iswitchb-mode -1))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11087
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11088 (defun org-buffer-list (&optional predicate tmp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11089 "Return a list of Org buffers.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11090 PREDICATE can be either 'export, 'files or 'agenda.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11091
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11092 'export restrict the list to Export buffers.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11093 'files restrict the list to buffers visiting Org files.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11094 'agenda restrict the list to buffers visiting agenda files.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11095
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11096 If TMP is non-nil, don't include temporary buffers."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11097 (let (filter blist)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11098 (setq filter
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11099 (cond ((eq predicate 'files) "\.org$")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11100 ((eq predicate 'export) "\*Org .*Export")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11101 (t "\*Org \\|\.org$")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11102 (setq blist
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11103 (mapcar
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11104 (lambda(b)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11105 (let ((bname (buffer-name b))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11106 (bfile (buffer-file-name b)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11107 (if (and (string-match filter bname)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11108 (if (eq predicate 'agenda)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11109 (member bfile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11110 (mapcar (lambda(f) (file-truename f))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11111 org-agenda-files)) t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11112 (if tmp (not (string-match "tmp" bname)) t)) b)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11113 (buffer-list)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11114 (delete nil blist)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11115
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11116 (defun org-agenda-files (&optional unrestricted ext)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11117 "Get the list of agenda files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11118 Optional UNRESTRICTED means return the full list even if a restriction
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11119 is currently in place.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11120 When EXT is non-nil, try to add all files that are created by adding EXT
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11121 to the file nemes. Basically, this is a way to add the archive files
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11122 to the list, by setting EXT to \"_archive\" If EXT is non-nil, but not
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11123 a string, \"_archive\" will be used."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11124 (let ((files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11125 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11126 ((and (not unrestricted) (get 'org-agenda-files 'org-restrict)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11127 ((stringp org-agenda-files) (org-read-agenda-file-list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11128 ((listp org-agenda-files) org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11129 (t (error "Invalid value of `org-agenda-files'")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11130 (setq files (apply 'append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11131 (mapcar (lambda (f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11132 (if (file-directory-p f)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11133 (directory-files
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11134 f t org-agenda-file-regexp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11135 (list f)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11136 files)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11137 (when org-agenda-skip-unavailable-files
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11138 (setq files (delq nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11139 (mapcar (function
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11140 (lambda (file)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11141 (and (file-readable-p file) file)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11142 files))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11143 (when ext
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11144 (setq ext (if (and (stringp ext) (string-match "\\S-" ext))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11145 ext "_archive"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11146 (setq files (apply 'append
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11147 (mapcar
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11148 (lambda (f)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11149 (if (file-exists-p (concat f ext))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11150 (list f (concat f ext))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11151 (list f)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11152 files))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11153 files))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11154
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11155 (defun org-edit-agenda-file-list ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11156 "Edit the list of agenda files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11157 Depending on setup, this either uses customize to edit the variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11158 `org-agenda-files', or it visits the file that is holding the list. In the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11159 latter case, the buffer is set up in a way that saving it automatically kills
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11160 the buffer and restores the previous window configuration."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11161 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11162 (if (stringp org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11163 (let ((cw (current-window-configuration)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11164 (find-file org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11165 (org-set-local 'org-window-configuration cw)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11166 (org-add-hook 'after-save-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11167 (lambda ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11168 (set-window-configuration
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11169 (prog1 org-window-configuration
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11170 (kill-buffer (current-buffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11171 (org-install-agenda-files-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11172 (message "New agenda file list installed"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11173 nil 'local)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11174 (message "%s" (substitute-command-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11175 "Edit list and finish with \\[save-buffer]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11176 (customize-variable 'org-agenda-files)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11177
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11178 (defun org-store-new-agenda-file-list (list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11179 "Set new value for the agenda file list and save it correcly."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11180 (if (stringp org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11181 (let ((f org-agenda-files) b)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11182 (while (setq b (find-buffer-visiting f)) (kill-buffer b))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11183 (with-temp-file f
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11184 (insert (mapconcat 'identity list "\n") "\n")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11185 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11186 (setq org-agenda-files list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11187 (customize-save-variable 'org-agenda-files org-agenda-files))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11188
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11189 (defun org-read-agenda-file-list ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11190 "Read the list of agenda files from a file."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11191 (when (file-directory-p org-agenda-files)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11192 (error "`org-agenda-files' cannot be a single directory"))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11193 (when (stringp org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11194 (with-temp-buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11195 (insert-file-contents org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11196 (org-split-string (buffer-string) "[ \t\r\n]*?[\r\n][ \t\r\n]*"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11197
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11198
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11199 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11200 (defun org-cycle-agenda-files ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11201 "Cycle through the files in `org-agenda-files'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11202 If the current buffer visits an agenda file, find the next one in the list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11203 If the current buffer does not, find the first agenda file."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11204 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11205 (let* ((fs (org-agenda-files t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11206 (files (append fs (list (car fs))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11207 (tcf (if buffer-file-name (file-truename buffer-file-name)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11208 file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11209 (unless files (error "No agenda files"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11210 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11211 (while (setq file (pop files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11212 (if (equal (file-truename file) tcf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11213 (when (car files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11214 (find-file (car files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11215 (throw 'exit t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11216 (find-file (car fs)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11217 (if (buffer-base-buffer) (switch-to-buffer (buffer-base-buffer)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11218
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11219 (defun org-agenda-file-to-front (&optional to-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11220 "Move/add the current file to the top of the agenda file list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11221 If the file is not present in the list, it is added to the front. If it is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11222 present, it is moved there. With optional argument TO-END, add/move to the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11223 end of the list."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11224 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11225 (let ((org-agenda-skip-unavailable-files nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11226 (file-alist (mapcar (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11227 (cons (file-truename x) x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11228 (org-agenda-files t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11229 (ctf (file-truename buffer-file-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11230 x had)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11231 (setq x (assoc ctf file-alist) had x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11232
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11233 (if (not x) (setq x (cons ctf (abbreviate-file-name buffer-file-name))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11234 (if to-end
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11235 (setq file-alist (append (delq x file-alist) (list x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11236 (setq file-alist (cons x (delq x file-alist))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11237 (org-store-new-agenda-file-list (mapcar 'cdr file-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11238 (org-install-agenda-files-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11239 (message "File %s to %s of agenda file list"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11240 (if had "moved" "added") (if to-end "end" "front"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11241
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11242 (defun org-remove-file (&optional file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11243 "Remove current file from the list of files in variable `org-agenda-files'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11244 These are the files which are being checked for agenda entries.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11245 Optional argument FILE means, use this file instead of the current."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11246 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11247 (let* ((org-agenda-skip-unavailable-files nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11248 (file (or file buffer-file-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11249 (true-file (file-truename file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11250 (afile (abbreviate-file-name file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11251 (files (delq nil (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11252 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11253 (if (equal true-file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11254 (file-truename x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11255 nil x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11256 (org-agenda-files t)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11257 (if (not (= (length files) (length (org-agenda-files t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11258 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11259 (org-store-new-agenda-file-list files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11260 (org-install-agenda-files-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11261 (message "Removed file: %s" afile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11262 (message "File was not in list: %s (not removed)" afile))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11263
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11264 (defun org-file-menu-entry (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11265 (vector file (list 'find-file file) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11266
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11267 (defun org-check-agenda-file (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11268 "Make sure FILE exists. If not, ask user what to do."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11269 (when (not (file-exists-p file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11270 (message "non-existent file %s. [R]emove from list or [A]bort?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11271 (abbreviate-file-name file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11272 (let ((r (downcase (read-char-exclusive))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11273 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11274 ((equal r ?r)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11275 (org-remove-file file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11276 (throw 'nextfile t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11277 (t (error "Abort"))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11278
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11279 (defun org-get-agenda-file-buffer (file)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11280 "Get a buffer visiting FILE. If the buffer needs to be created, add
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11281 it to the list of buffers which might be released later."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11282 (let ((buf (org-find-base-buffer-visiting file)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11283 (if buf
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11284 buf ; just return it
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11285 ;; Make a new buffer and remember it
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11286 (setq buf (find-file-noselect file))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11287 (if buf (push buf org-agenda-new-buffers))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11288 buf)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11289
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11290 (defun org-release-buffers (blist)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11291 "Release all buffers in list, asking the user for confirmation when needed.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11292 When a buffer is unmodified, it is just killed. When modified, it is saved
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11293 \(if the user agrees) and then killed."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11294 (let (buf file)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11295 (while (setq buf (pop blist))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11296 (setq file (buffer-file-name buf))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11297 (when (and (buffer-modified-p buf)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11298 file
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11299 (y-or-n-p (format "Save file %s? " file)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11300 (with-current-buffer buf (save-buffer)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11301 (kill-buffer buf))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11302
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11303 (defun org-prepare-agenda-buffers (files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11304 "Create buffers for all agenda files, protect archived trees and comments."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11305 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11306 (let ((pa '(:org-archived t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11307 (pc '(:org-comment t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11308 (pall '(:org-archived t :org-comment t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11309 (inhibit-read-only t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11310 (rea (concat ":" org-archive-tag ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11311 bmp file re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11312 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11313 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11314 (while (setq file (pop files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11315 (if (bufferp file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11316 (set-buffer file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11317 (org-check-agenda-file file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11318 (set-buffer (org-get-agenda-file-buffer file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11319 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11320 (setq bmp (buffer-modified-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11321 (org-refresh-category-properties)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11322 (setq org-todo-keywords-for-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11323 (append org-todo-keywords-for-agenda org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11324 (setq org-done-keywords-for-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11325 (append org-done-keywords-for-agenda org-done-keywords))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11326 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11327 (remove-text-properties (point-min) (point-max) pall)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11328 (when org-agenda-skip-archived-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11329 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11330 (while (re-search-forward rea nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11331 (if (org-on-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11332 (add-text-properties (point-at-bol) (org-end-of-subtree t) pa))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11333 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11334 (setq re (concat "^\\*+ +" org-comment-string "\\>"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11335 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11336 (add-text-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11337 (match-beginning 0) (org-end-of-subtree t) pc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11338 (set-buffer-modified-p bmp))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11339
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11340 ;;;; Embedded LaTeX
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11341
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11342 (defvar org-cdlatex-mode-map (make-sparse-keymap)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11343 "Keymap for the minor `org-cdlatex-mode'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11344
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11345 (org-defkey org-cdlatex-mode-map "_" 'org-cdlatex-underscore-caret)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11346 (org-defkey org-cdlatex-mode-map "^" 'org-cdlatex-underscore-caret)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11347 (org-defkey org-cdlatex-mode-map "`" 'cdlatex-math-symbol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11348 (org-defkey org-cdlatex-mode-map "'" 'org-cdlatex-math-modify)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11349 (org-defkey org-cdlatex-mode-map "\C-c{" 'cdlatex-environment)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11350
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11351 (defvar org-cdlatex-texmathp-advice-is-done nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11352 "Flag remembering if we have applied the advice to texmathp already.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11353
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11354 (define-minor-mode org-cdlatex-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11355 "Toggle the minor `org-cdlatex-mode'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11356 This mode supports entering LaTeX environment and math in LaTeX fragments
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11357 in Org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11358 \\{org-cdlatex-mode-map}"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11359 nil " OCDL" nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11360 (when org-cdlatex-mode (require 'cdlatex))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11361 (unless org-cdlatex-texmathp-advice-is-done
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11362 (setq org-cdlatex-texmathp-advice-is-done t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11363 (defadvice texmathp (around org-math-always-on activate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11364 "Always return t in org-mode buffers.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11365 This is because we want to insert math symbols without dollars even outside
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11366 the LaTeX math segments. If Orgmode thinks that point is actually inside
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11367 en embedded LaTeX fragement, let texmathp do its job.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11368 \\[org-cdlatex-mode-map]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11369 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11370 (let (p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11371 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11372 ((not (org-mode-p)) ad-do-it)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11373 ((eq this-command 'cdlatex-math-symbol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11374 (setq ad-return-value t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11375 texmathp-why '("cdlatex-math-symbol in org-mode" . 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11376 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11377 (let ((p (org-inside-LaTeX-fragment-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11378 (if (and p (member (car p) (plist-get org-format-latex-options :matchers)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11379 (setq ad-return-value t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11380 texmathp-why '("Org-mode embedded math" . 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11381 (if p ad-do-it)))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11382
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11383 (defun turn-on-org-cdlatex ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11384 "Unconditionally turn on `org-cdlatex-mode'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11385 (org-cdlatex-mode 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11386
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11387 (defun org-inside-LaTeX-fragment-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11388 "Test if point is inside a LaTeX fragment.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11389 I.e. after a \\begin, \\(, \\[, $, or $$, without the corresponding closing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11390 sequence appearing also before point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11391 Even though the matchers for math are configurable, this function assumes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11392 that \\begin, \\(, \\[, and $$ are always used. Only the single dollar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11393 delimiters are skipped when they have been removed by customization.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11394 The return value is nil, or a cons cell with the delimiter and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11395 and the position of this delimiter.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11396
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11397 This function does a reasonably good job, but can locally be fooled by
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11398 for example currency specifications. For example it will assume being in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11399 inline math after \"$22.34\". The LaTeX fragment formatter will only format
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11400 fragments that are properly closed, but during editing, we have to live
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11401 with the uncertainty caused by missing closing delimiters. This function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11402 looks only before point, not after."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11403 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11404 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11405 (dodollar (member "$" (plist-get org-format-latex-options :matchers)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11406 (lim (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11407 (re-search-backward (concat "^\\(" paragraph-start "\\)") nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11408 (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11409 dd-on str (start 0) m re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11410 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11411 (when dodollar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11412 (setq str (concat (buffer-substring lim (point)) "\000 X$.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11413 re (nth 1 (assoc "$" org-latex-regexps)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11414 (while (string-match re str start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11415 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11416 ((= (match-end 0) (length str))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11417 (throw 'exit (cons "$" (+ lim (match-beginning 0) 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11418 ((= (match-end 0) (- (length str) 5))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11419 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11420 (t (setq start (match-end 0))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11421 (when (setq m (re-search-backward "\\(\\\\begin{[^}]*}\\|\\\\(\\|\\\\\\[\\)\\|\\(\\\\end{[^}]*}\\|\\\\)\\|\\\\\\]\\)\\|\\(\\$\\$\\)" lim t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11422 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11423 (and (match-beginning 1) (throw 'exit (cons (match-string 1) m)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11424 (and (match-beginning 2) (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11425 ;; count $$
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11426 (while (re-search-backward "\\$\\$" lim t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11427 (setq dd-on (not dd-on)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11428 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11429 (if dd-on (cons "$$" m))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11430
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11431
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11432 (defun org-try-cdlatex-tab ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11433 "Check if it makes sense to execute `cdlatex-tab', and do it if yes.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11434 It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11435 - inside a LaTeX fragment, or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11436 - after the first word in a line, where an abbreviation expansion could
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11437 insert a LaTeX environment."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11438 (when org-cdlatex-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11439 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11440 ((save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11441 (skip-chars-backward "a-zA-Z0-9*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11442 (skip-chars-backward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11443 (bolp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11444 (cdlatex-tab) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11445 ((org-inside-LaTeX-fragment-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11446 (cdlatex-tab) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11447 (t nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11448
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11449 (defun org-cdlatex-underscore-caret (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11450 "Execute `cdlatex-sub-superscript' in LaTeX fragments.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11451 Revert to the normal definition outside of these fragments."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11452 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11453 (if (org-inside-LaTeX-fragment-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11454 (call-interactively 'cdlatex-sub-superscript)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11455 (let (org-cdlatex-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11456 (call-interactively (key-binding (vector last-input-event))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11457
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11458 (defun org-cdlatex-math-modify (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11459 "Execute `cdlatex-math-modify' in LaTeX fragments.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11460 Revert to the normal definition outside of these fragments."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11461 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11462 (if (org-inside-LaTeX-fragment-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11463 (call-interactively 'cdlatex-math-modify)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11464 (let (org-cdlatex-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11465 (call-interactively (key-binding (vector last-input-event))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11466
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11467 (defvar org-latex-fragment-image-overlays nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11468 "List of overlays carrying the images of latex fragments.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11469 (make-variable-buffer-local 'org-latex-fragment-image-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11470
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11471 (defun org-remove-latex-fragment-image-overlays ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11472 "Remove all overlays with LaTeX fragment images in current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11473 (mapc 'org-delete-overlay org-latex-fragment-image-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11474 (setq org-latex-fragment-image-overlays nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11475
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11476 (defun org-preview-latex-fragment (&optional subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11477 "Preview the LaTeX fragment at point, or all locally or globally.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11478 If the cursor is in a LaTeX fragment, create the image and overlay
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11479 it over the source code. If there is no fragment at point, display
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11480 all fragments in the current text, from one headline to the next. With
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11481 prefix SUBTREE, display all fragments in the current subtree. With a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11482 double prefix `C-u C-u', or when the cursor is before the first headline,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11483 display all fragments in the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11484 The images can be removed again with \\[org-ctrl-c-ctrl-c]."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11485 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11486 (org-remove-latex-fragment-image-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11487 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11488 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11489 (let (beg end at msg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11490 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11491 ((or (equal subtree '(16))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11492 (not (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11493 (re-search-backward (concat "^" outline-regexp) nil t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11494 (setq beg (point-min) end (point-max)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11495 msg "Creating images for buffer...%s"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11496 ((equal subtree '(4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11497 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11498 (setq beg (point) end (org-end-of-subtree t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11499 msg "Creating images for subtree...%s"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11500 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11501 (if (setq at (org-inside-LaTeX-fragment-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11502 (goto-char (max (point-min) (- (cdr at) 2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11503 (org-back-to-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11504 (setq beg (point) end (progn (outline-next-heading) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11505 msg (if at "Creating image...%s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11506 "Creating images for entry...%s"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11507 (message msg "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11508 (narrow-to-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11509 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11510 (org-format-latex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11511 (concat "ltxpng/" (file-name-sans-extension
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11512 (file-name-nondirectory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11513 buffer-file-name)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11514 default-directory 'overlays msg at 'forbuffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11515 (message msg "done. Use `C-c C-c' to remove images.")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11516
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11517 (defvar org-latex-regexps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11518 '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11519 ;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([ .,?;:'\")]\\|$\\)" 2 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11520 ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11521 ("$" "\\([^$]\\)\\(\\(\\$\\([^ \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \r\n,.$]\\)\\$\\)\\)\\([ .,?;:'\")\000]\\|$\\)" 2 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11522 ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11523 ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11524 ("$$" "\\$\\$[^\000]*?\\$\\$" 0 t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11525 "Regular expressions for matching embedded LaTeX.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11526
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11527 (defun org-format-latex (prefix &optional dir overlays msg at forbuffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11528 "Replace LaTeX fragments with links to an image, and produce images."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11529 (if (and overlays (fboundp 'clear-image-cache)) (clear-image-cache))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11530 (let* ((prefixnodir (file-name-nondirectory prefix))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11531 (absprefix (expand-file-name prefix dir))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11532 (todir (file-name-directory absprefix))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11533 (opt org-format-latex-options)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11534 (matchers (plist-get opt :matchers))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11535 (re-list org-latex-regexps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11536 (cnt 0) txt link beg end re e checkdir
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11537 m n block linkfile movefile ov)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11538 ;; Check if there are old images files with this prefix, and remove them
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11539 (when (file-directory-p todir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11540 (mapc 'delete-file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11541 (directory-files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11542 todir 'full
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11543 (concat (regexp-quote prefixnodir) "_[0-9]+\\.png$"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11544 ;; Check the different regular expressions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11545 (while (setq e (pop re-list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11546 (setq m (car e) re (nth 1 e) n (nth 2 e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11547 block (if (nth 3 e) "\n\n" ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11548 (when (member m matchers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11549 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11550 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11551 (when (or (not at) (equal (cdr at) (match-beginning n)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11552 (setq txt (match-string n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11553 beg (match-beginning n) end (match-end n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11554 cnt (1+ cnt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11555 linkfile (format "%s_%04d.png" prefix cnt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11556 movefile (format "%s_%04d.png" absprefix cnt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11557 link (concat block "[[file:" linkfile "]]" block))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11558 (if msg (message msg cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11559 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11560 (unless checkdir ; make sure the directory exists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11561 (setq checkdir t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11562 (or (file-directory-p todir) (make-directory todir)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11563 (org-create-formula-image
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11564 txt movefile opt forbuffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11565 (if overlays
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11566 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11567 (setq ov (org-make-overlay beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11568 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11569 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11570 (org-overlay-put ov 'invisible t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11571 (org-overlay-put
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11572 ov 'end-glyph
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11573 (make-glyph (vector 'png :file movefile))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11574 (org-overlay-put
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11575 ov 'display
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11576 (list 'image :type 'png :file movefile :ascent 'center)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11577 (push ov org-latex-fragment-image-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11578 (goto-char end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11579 (delete-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11580 (insert link))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11581
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11582 ;; This function borrows from Ganesh Swami's latex2png.el
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11583 (defun org-create-formula-image (string tofile options buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11584 (let* ((tmpdir (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11585 (temp-directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11586 temporary-file-directory))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11587 (texfilebase (make-temp-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11588 (expand-file-name "orgtex" tmpdir)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11589 (texfile (concat texfilebase ".tex"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11590 (dvifile (concat texfilebase ".dvi"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11591 (pngfile (concat texfilebase ".png"))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11592 (fnh (if (featurep 'xemacs)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11593 (font-height (get-face-font 'default))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11594 (face-attribute 'default :height nil)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11595 (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11596 (dpi (number-to-string (* scale (floor (* 0.9 (if buffer fnh 140.))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11597 (fg (or (plist-get options (if buffer :foreground :html-foreground))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11598 "Black"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11599 (bg (or (plist-get options (if buffer :background :html-background))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11600 "Transparent")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11601 (if (eq fg 'default) (setq fg (org-dvipng-color :foreground)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11602 (if (eq bg 'default) (setq bg (org-dvipng-color :background)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11603 (with-temp-file texfile
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11604 (insert org-format-latex-header
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11605 "\n\\begin{document}\n" string "\n\\end{document}\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11606 (let ((dir default-directory))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11607 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11608 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11609 (cd tmpdir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11610 (call-process "latex" nil nil nil texfile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11611 (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11612 (cd dir))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11613 (if (not (file-exists-p dvifile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11614 (progn (message "Failed to create dvi file from %s" texfile) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11615 (call-process "dvipng" nil nil nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11616 "-E" "-fg" fg "-bg" bg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11617 "-D" dpi
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11618 ;;"-x" scale "-y" scale
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11619 "-T" "tight"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11620 "-o" pngfile
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11621 dvifile)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11622 (if (not (file-exists-p pngfile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11623 (progn (message "Failed to create png file from %s" texfile) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11624 ;; Use the requested file name and clean up
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11625 (copy-file pngfile tofile 'replace)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11626 (loop for e in '(".dvi" ".tex" ".aux" ".log" ".png") do
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11627 (delete-file (concat texfilebase e)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11628 pngfile))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11629
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11630 (defun org-dvipng-color (attr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11631 "Return an rgb color specification for dvipng."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11632 (apply 'format "rgb %s %s %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11633 (mapcar 'org-normalize-color
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11634 (color-values (face-attribute 'default attr nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11635
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11636 (defun org-normalize-color (value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11637 "Return string to be used as color value for an RGB component."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11638 (format "%g" (/ value 65535.0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11639
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11640
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11641 ;;;; Key bindings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11642
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11643 ;; Make `C-c C-x' a prefix key
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11644 (org-defkey org-mode-map "\C-c\C-x" (make-sparse-keymap))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11645
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11646 ;; TAB key with modifiers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11647 (org-defkey org-mode-map "\C-i" 'org-cycle)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11648 (org-defkey org-mode-map [(tab)] 'org-cycle)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11649 (org-defkey org-mode-map [(control tab)] 'org-force-cycle-archived)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11650 (org-defkey org-mode-map [(meta tab)] 'org-complete)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11651 (org-defkey org-mode-map "\M-\t" 'org-complete)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11652 (org-defkey org-mode-map "\M-\C-i" 'org-complete)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11653 ;; The following line is necessary under Suse GNU/Linux
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11654 (unless (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11655 (org-defkey org-mode-map [S-iso-lefttab] 'org-shifttab))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11656 (org-defkey org-mode-map [(shift tab)] 'org-shifttab)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11657 (define-key org-mode-map [backtab] 'org-shifttab)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11658
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11659 (org-defkey org-mode-map [(shift return)] 'org-table-copy-down)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11660 (org-defkey org-mode-map [(meta shift return)] 'org-insert-todo-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11661 (org-defkey org-mode-map [(meta return)] 'org-meta-return)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11662
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11663 ;; Cursor keys with modifiers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11664 (org-defkey org-mode-map [(meta left)] 'org-metaleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11665 (org-defkey org-mode-map [(meta right)] 'org-metaright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11666 (org-defkey org-mode-map [(meta up)] 'org-metaup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11667 (org-defkey org-mode-map [(meta down)] 'org-metadown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11668
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11669 (org-defkey org-mode-map [(meta shift left)] 'org-shiftmetaleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11670 (org-defkey org-mode-map [(meta shift right)] 'org-shiftmetaright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11671 (org-defkey org-mode-map [(meta shift up)] 'org-shiftmetaup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11672 (org-defkey org-mode-map [(meta shift down)] 'org-shiftmetadown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11673
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11674 (org-defkey org-mode-map [(shift up)] 'org-shiftup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11675 (org-defkey org-mode-map [(shift down)] 'org-shiftdown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11676 (org-defkey org-mode-map [(shift left)] 'org-shiftleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11677 (org-defkey org-mode-map [(shift right)] 'org-shiftright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11678
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11679 (org-defkey org-mode-map [(control shift right)] 'org-shiftcontrolright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11680 (org-defkey org-mode-map [(control shift left)] 'org-shiftcontrolleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11681
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11682 ;;; Extra keys for tty access.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11683 ;; We only set them when really needed because otherwise the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11684 ;; menus don't show the simple keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11685
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11686 (when (or (featurep 'xemacs) ;; because XEmacs supports multi-device stuff
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11687 (not window-system))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11688 (org-defkey org-mode-map "\C-c\C-xc" 'org-table-copy-down)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11689 (org-defkey org-mode-map "\C-c\C-xM" 'org-insert-todo-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11690 (org-defkey org-mode-map "\C-c\C-xm" 'org-meta-return)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11691 (org-defkey org-mode-map [?\e (return)] 'org-meta-return)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11692 (org-defkey org-mode-map [?\e (left)] 'org-metaleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11693 (org-defkey org-mode-map "\C-c\C-xl" 'org-metaleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11694 (org-defkey org-mode-map [?\e (right)] 'org-metaright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11695 (org-defkey org-mode-map "\C-c\C-xr" 'org-metaright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11696 (org-defkey org-mode-map [?\e (up)] 'org-metaup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11697 (org-defkey org-mode-map "\C-c\C-xu" 'org-metaup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11698 (org-defkey org-mode-map [?\e (down)] 'org-metadown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11699 (org-defkey org-mode-map "\C-c\C-xd" 'org-metadown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11700 (org-defkey org-mode-map "\C-c\C-xL" 'org-shiftmetaleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11701 (org-defkey org-mode-map "\C-c\C-xR" 'org-shiftmetaright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11702 (org-defkey org-mode-map "\C-c\C-xU" 'org-shiftmetaup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11703 (org-defkey org-mode-map "\C-c\C-xD" 'org-shiftmetadown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11704 (org-defkey org-mode-map [?\C-c (up)] 'org-shiftup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11705 (org-defkey org-mode-map [?\C-c (down)] 'org-shiftdown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11706 (org-defkey org-mode-map [?\C-c (left)] 'org-shiftleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11707 (org-defkey org-mode-map [?\C-c (right)] 'org-shiftright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11708 (org-defkey org-mode-map [?\C-c ?\C-x (right)] 'org-shiftcontrolright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11709 (org-defkey org-mode-map [?\C-c ?\C-x (left)] 'org-shiftcontrolleft))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11710
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11711 ;; All the other keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11712
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11713 (org-defkey org-mode-map "\C-c\C-a" 'show-all) ; in case allout messed up.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11714 (org-defkey org-mode-map "\C-c\C-r" 'org-reveal)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11715 (org-defkey org-mode-map "\C-xns" 'org-narrow-to-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11716 (org-defkey org-mode-map "\C-c$" 'org-archive-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11717 (org-defkey org-mode-map "\C-c\C-x\C-s" 'org-advertized-archive-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11718 (org-defkey org-mode-map "\C-c\C-x\C-a" 'org-toggle-archive-tag)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11719 (org-defkey org-mode-map "\C-c\C-xa" 'org-toggle-archive-tag)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11720 (org-defkey org-mode-map "\C-c\C-xA" 'org-archive-to-archive-sibling)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11721 (org-defkey org-mode-map "\C-c\C-xb" 'org-tree-to-indirect-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11722 (org-defkey org-mode-map "\C-c\C-j" 'org-goto)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11723 (org-defkey org-mode-map "\C-c\C-t" 'org-todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11724 (org-defkey org-mode-map "\C-c\C-s" 'org-schedule)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11725 (org-defkey org-mode-map "\C-c\C-d" 'org-deadline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11726 (org-defkey org-mode-map "\C-c;" 'org-toggle-comment)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11727 (org-defkey org-mode-map "\C-c\C-v" 'org-show-todo-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11728 (org-defkey org-mode-map "\C-c\C-w" 'org-refile)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11729 (org-defkey org-mode-map "\C-c/" 'org-sparse-tree) ; Minor-mode reserved
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11730 (org-defkey org-mode-map "\C-c\\" 'org-tags-sparse-tree) ; Minor-mode res.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11731 (org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11732 (org-defkey org-mode-map "\M-\C-m" 'org-insert-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11733 (org-defkey org-mode-map [(control return)] 'org-insert-heading-after-current)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11734 (org-defkey org-mode-map "\C-c\C-x\C-n" 'org-next-link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11735 (org-defkey org-mode-map "\C-c\C-x\C-p" 'org-previous-link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11736 (org-defkey org-mode-map "\C-c\C-l" 'org-insert-link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11737 (org-defkey org-mode-map "\C-c\C-o" 'org-open-at-point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11738 (org-defkey org-mode-map "\C-c%" 'org-mark-ring-push)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11739 (org-defkey org-mode-map "\C-c&" 'org-mark-ring-goto)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11740 (org-defkey org-mode-map "\C-c\C-z" 'org-add-note) ; Alternative binding
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11741 (org-defkey org-mode-map "\C-c." 'org-time-stamp) ; Minor-mode reserved
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11742 (org-defkey org-mode-map "\C-c!" 'org-time-stamp-inactive) ; Minor-mode r.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11743 (org-defkey org-mode-map "\C-c," 'org-priority) ; Minor-mode reserved
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11744 (org-defkey org-mode-map "\C-c\C-y" 'org-evaluate-time-range)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11745 (org-defkey org-mode-map "\C-c>" 'org-goto-calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11746 (org-defkey org-mode-map "\C-c<" 'org-date-from-calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11747 (org-defkey org-mode-map [(control ?,)] 'org-cycle-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11748 (org-defkey org-mode-map [(control ?\')] 'org-cycle-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11749 (org-defkey org-mode-map "\C-c[" 'org-agenda-file-to-front)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11750 (org-defkey org-mode-map "\C-c]" 'org-remove-file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11751 (org-defkey org-mode-map "\C-c\C-x<" 'org-agenda-set-restriction-lock)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11752 (org-defkey org-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11753 (org-defkey org-mode-map "\C-c-" 'org-ctrl-c-minus)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11754 (org-defkey org-mode-map "\C-c*" 'org-ctrl-c-star)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11755 (org-defkey org-mode-map "\C-c^" 'org-sort)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11756 (org-defkey org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11757 (org-defkey org-mode-map "\C-c\C-k" 'org-kill-note-or-show-branches)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11758 (org-defkey org-mode-map "\C-c#" 'org-update-checkbox-count)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11759 (org-defkey org-mode-map "\C-m" 'org-return)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11760 (org-defkey org-mode-map "\C-j" 'org-return-indent)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11761 (org-defkey org-mode-map "\C-c?" 'org-table-field-info)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11762 (org-defkey org-mode-map "\C-c " 'org-table-blank-field)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11763 (org-defkey org-mode-map "\C-c+" 'org-table-sum)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11764 (org-defkey org-mode-map "\C-c=" 'org-table-eval-formula)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11765 (org-defkey org-mode-map "\C-c'" 'org-table-edit-formulas)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11766 (org-defkey org-mode-map "\C-c`" 'org-table-edit-field)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11767 (org-defkey org-mode-map "\C-c|" 'org-table-create-or-convert-from-region)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11768 (org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11769 (org-defkey org-mode-map "\C-c~" 'org-table-create-with-table.el)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11770 (org-defkey org-mode-map "\C-c\C-q" 'org-table-wrap-region)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11771 (org-defkey org-mode-map "\C-c}" 'org-table-toggle-coordinate-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11772 (org-defkey org-mode-map "\C-c{" 'org-table-toggle-formula-debugger)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11773 (org-defkey org-mode-map "\C-c\C-e" 'org-export)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11774 (org-defkey org-mode-map "\C-c:" 'org-toggle-fixed-width-section)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11775 (org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11776
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11777 (org-defkey org-mode-map "\C-c\C-x\C-k" 'org-cut-special)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11778 (org-defkey org-mode-map "\C-c\C-x\C-w" 'org-cut-special)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11779 (org-defkey org-mode-map "\C-c\C-x\M-w" 'org-copy-special)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11780 (org-defkey org-mode-map "\C-c\C-x\C-y" 'org-paste-special)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11781
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11782 (org-defkey org-mode-map "\C-c\C-x\C-t" 'org-toggle-time-stamp-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11783 (org-defkey org-mode-map "\C-c\C-x\C-i" 'org-clock-in)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11784 (org-defkey org-mode-map "\C-c\C-x\C-o" 'org-clock-out)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11785 (org-defkey org-mode-map "\C-c\C-x\C-j" 'org-clock-goto)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11786 (org-defkey org-mode-map "\C-c\C-x\C-x" 'org-clock-cancel)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11787 (org-defkey org-mode-map "\C-c\C-x\C-d" 'org-clock-display)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11788 (org-defkey org-mode-map "\C-c\C-x\C-r" 'org-clock-report)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11789 (org-defkey org-mode-map "\C-c\C-x\C-u" 'org-dblock-update)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11790 (org-defkey org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11791 (org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11792 (org-defkey org-mode-map "\C-c\C-xp" 'org-set-property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11793 (org-defkey org-mode-map "\C-c\C-xr" 'org-insert-columns-dblock)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11794
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11795 (define-key org-mode-map "\C-c\C-x\C-c" 'org-columns)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11796
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11797 (when (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11798 (org-defkey org-mode-map 'button3 'popup-mode-menu))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11799
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11800 (defvar org-table-auto-blank-field) ; defined in org-table.el
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11801 (defun org-self-insert-command (N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11802 "Like `self-insert-command', use overwrite-mode for whitespace in tables.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11803 If the cursor is in a table looking at whitespace, the whitespace is
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11804 overwritten, and the table is not marked as requiring realignment."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11805 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11806 (if (and (org-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11807 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11808 ;; check if we blank the field, and if that triggers align
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11809 (and (featurep 'org-table) org-table-auto-blank-field
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11810 (member last-command
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11811 '(org-cycle org-return org-shifttab org-ctrl-c-ctrl-c))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11812 (if (or (equal (char-after) ?\ ) (looking-at "[^|\n]* |"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11813 ;; got extra space, this field does not determine column width
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11814 (let (org-table-may-need-update) (org-table-blank-field))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11815 ;; no extra space, this field may determine column width
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11816 (org-table-blank-field)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11817 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11818 (eq N 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11819 (looking-at "[^|\n]* |"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11820 (let (org-table-may-need-update)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11821 (goto-char (1- (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11822 (delete-backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11823 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11824 (self-insert-command N))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11825 (setq org-table-may-need-update t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11826 (self-insert-command N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11827 (org-fix-tags-on-the-fly)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11828
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11829 (defun org-fix-tags-on-the-fly ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11830 (when (and (equal (char-after (point-at-bol)) ?*)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11831 (org-on-heading-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11832 (org-align-tags-here org-tags-column)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11833
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11834 (defun org-delete-backward-char (N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11835 "Like `delete-backward-char', insert whitespace at field end in tables.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11836 When deleting backwards, in tables this function will insert whitespace in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11837 front of the next \"|\" separator, to keep the table aligned. The table will
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11838 still be marked for re-alignment if the field did fill the entire column,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11839 because, in this case the deletion might narrow the column."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11840 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11841 (if (and (org-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11842 (eq N 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11843 (string-match "|" (buffer-substring (point-at-bol) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11844 (looking-at ".*?|"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11845 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11846 (noalign (looking-at "[^|\n\r]* |"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11847 (c org-table-may-need-update))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11848 (backward-delete-char N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11849 (skip-chars-forward "^|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11850 (insert " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11851 (goto-char (1- pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11852 ;; noalign: if there were two spaces at the end, this field
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11853 ;; does not determine the width of the column.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11854 (if noalign (setq org-table-may-need-update c)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11855 (backward-delete-char N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11856 (org-fix-tags-on-the-fly)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11857
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11858 (defun org-delete-char (N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11859 "Like `delete-char', but insert whitespace at field end in tables.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11860 When deleting characters, in tables this function will insert whitespace in
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11861 front of the next \"|\" separator, to keep the table aligned. The table will
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11862 still be marked for re-alignment if the field did fill the entire column,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11863 because, in this case the deletion might narrow the column."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11864 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11865 (if (and (org-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11866 (not (bolp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11867 (not (= (char-after) ?|))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11868 (eq N 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11869 (if (looking-at ".*?|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11870 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11871 (noalign (looking-at "[^|\n\r]* |"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11872 (c org-table-may-need-update))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11873 (replace-match (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11874 (substring (match-string 0) 1 -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11875 " |"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11876 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11877 ;; noalign: if there were two spaces at the end, this field
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11878 ;; does not determine the width of the column.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11879 (if noalign (setq org-table-may-need-update c)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11880 (delete-char N))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11881 (delete-char N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11882 (org-fix-tags-on-the-fly)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11883
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11884 ;; Make `delete-selection-mode' work with org-mode and orgtbl-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11885 (put 'org-self-insert-command 'delete-selection t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11886 (put 'orgtbl-self-insert-command 'delete-selection t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11887 (put 'org-delete-char 'delete-selection 'supersede)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11888 (put 'org-delete-backward-char 'delete-selection 'supersede)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11889
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11890 ;; Make `flyspell-mode' delay after some commands
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11891 (put 'org-self-insert-command 'flyspell-delayed t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11892 (put 'orgtbl-self-insert-command 'flyspell-delayed t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11893 (put 'org-delete-char 'flyspell-delayed t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11894 (put 'org-delete-backward-char 'flyspell-delayed t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11895
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11896 ;; Make pabbrev-mode expand after org-mode commands
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11897 (put 'org-self-insert-command 'pabbrev-expand-after-command t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11898 (put 'orgybl-self-insert-command 'pabbrev-expand-after-command t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11899
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11900 ;; How to do this: Measure non-white length of current string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11901 ;; If equal to column width, we should realign.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11902
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11903 (defun org-remap (map &rest commands)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11904 "In MAP, remap the functions given in COMMANDS.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11905 COMMANDS is a list of alternating OLDDEF NEWDEF command names."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11906 (let (new old)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11907 (while commands
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11908 (setq old (pop commands) new (pop commands))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11909 (if (fboundp 'command-remapping)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11910 (org-defkey map (vector 'remap old) new)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11911 (substitute-key-definition old new map global-map)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11912
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11913 (when (eq org-enable-table-editor 'optimized)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11914 ;; If the user wants maximum table support, we need to hijack
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11915 ;; some standard editing functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11916 (org-remap org-mode-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11917 'self-insert-command 'org-self-insert-command
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11918 'delete-char 'org-delete-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11919 'delete-backward-char 'org-delete-backward-char)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11920 (org-defkey org-mode-map "|" 'org-force-self-insert))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11921
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11922 (defun org-shiftcursor-error ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11923 "Throw an error because Shift-Cursor command was applied in wrong context."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11924 (error "This command is active in special context like tables, headlines or timestamps"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11925
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11926 (defun org-shifttab (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11927 "Global visibility cycling or move to previous table field.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11928 Calls `org-cycle' with argument t, or `org-table-previous-field', depending
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11929 on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11930 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11931 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11932 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11933 ((org-at-table-p) (call-interactively 'org-table-previous-field))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11934 (arg (message "Content view to level: ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11935 (org-content (prefix-numeric-value arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11936 (setq org-cycle-global-status 'overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11937 (t (call-interactively 'org-global-cycle))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11938
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11939 (defun org-shiftmetaleft ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11940 "Promote subtree or delete table column.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11941 Calls `org-promote-subtree', `org-outdent-item',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11942 or `org-table-delete-column', depending on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11943 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11944 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11945 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11946 ((org-at-table-p) (call-interactively 'org-table-delete-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11947 ((org-on-heading-p) (call-interactively 'org-promote-subtree))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11948 ((org-at-item-p) (call-interactively 'org-outdent-item))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11949 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11950
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11951 (defun org-shiftmetaright ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11952 "Demote subtree or insert table column.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11953 Calls `org-demote-subtree', `org-indent-item',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11954 or `org-table-insert-column', depending on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11955 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11956 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11957 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11958 ((org-at-table-p) (call-interactively 'org-table-insert-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11959 ((org-on-heading-p) (call-interactively 'org-demote-subtree))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11960 ((org-at-item-p) (call-interactively 'org-indent-item))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11961 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11962
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11963 (defun org-shiftmetaup (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11964 "Move subtree up or kill table row.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11965 Calls `org-move-subtree-up' or `org-table-kill-row' or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11966 `org-move-item-up' depending on context. See the individual commands
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11967 for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11968 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11969 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11970 ((org-at-table-p) (call-interactively 'org-table-kill-row))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11971 ((org-on-heading-p) (call-interactively 'org-move-subtree-up))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11972 ((org-at-item-p) (call-interactively 'org-move-item-up))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11973 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11974 (defun org-shiftmetadown (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11975 "Move subtree down or insert table row.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11976 Calls `org-move-subtree-down' or `org-table-insert-row' or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11977 `org-move-item-down', depending on context. See the individual
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11978 commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11979 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11980 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11981 ((org-at-table-p) (call-interactively 'org-table-insert-row))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11982 ((org-on-heading-p) (call-interactively 'org-move-subtree-down))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11983 ((org-at-item-p) (call-interactively 'org-move-item-down))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11984 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11985
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11986 (defun org-metaleft (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11987 "Promote heading or move table column to left.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11988 Calls `org-do-promote' or `org-table-move-column', depending on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11989 With no specific context, calls the Emacs default `backward-word'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11990 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11991 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11992 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11993 ((org-at-table-p) (org-call-with-arg 'org-table-move-column 'left))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11994 ((or (org-on-heading-p) (org-region-active-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11995 (call-interactively 'org-do-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11996 ((org-at-item-p) (call-interactively 'org-outdent-item))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11997 (t (call-interactively 'backward-word))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11998
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11999 (defun org-metaright (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12000 "Demote subtree or move table column to right.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12001 Calls `org-do-demote' or `org-table-move-column', depending on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12002 With no specific context, calls the Emacs default `forward-word'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12003 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12004 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12005 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12006 ((org-at-table-p) (call-interactively 'org-table-move-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12007 ((or (org-on-heading-p) (org-region-active-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12008 (call-interactively 'org-do-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12009 ((org-at-item-p) (call-interactively 'org-indent-item))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12010 (t (call-interactively 'forward-word))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12011
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12012 (defun org-metaup (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12013 "Move subtree up or move table row up.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12014 Calls `org-move-subtree-up' or `org-table-move-row' or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12015 `org-move-item-up', depending on context. See the individual commands
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12016 for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12017 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12018 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12019 ((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12020 ((org-on-heading-p) (call-interactively 'org-move-subtree-up))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12021 ((org-at-item-p) (call-interactively 'org-move-item-up))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12022 (t (transpose-lines 1) (beginning-of-line -1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12023
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12024 (defun org-metadown (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12025 "Move subtree down or move table row down.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12026 Calls `org-move-subtree-down' or `org-table-move-row' or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12027 `org-move-item-down', depending on context. See the individual
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12028 commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12029 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12030 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12031 ((org-at-table-p) (call-interactively 'org-table-move-row))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12032 ((org-on-heading-p) (call-interactively 'org-move-subtree-down))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12033 ((org-at-item-p) (call-interactively 'org-move-item-down))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12034 (t (beginning-of-line 2) (transpose-lines 1) (beginning-of-line 0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12035
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12036 (defun org-shiftup (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12037 "Increase item in timestamp or increase priority of current headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12038 Calls `org-timestamp-up' or `org-priority-up', or `org-previous-item',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12039 depending on context. See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12040 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12041 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12042 ((org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12043 (call-interactively (if org-edit-timestamp-down-means-later
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12044 'org-timestamp-down 'org-timestamp-up)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12045 ((org-on-heading-p) (call-interactively 'org-priority-up))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12046 ((org-at-item-p) (call-interactively 'org-previous-item))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12047 ((org-clocktable-try-shift 'up arg))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12048 (t (call-interactively 'org-beginning-of-item) (beginning-of-line 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12049
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12050 (defun org-shiftdown (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12051 "Decrease item in timestamp or decrease priority of current headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12052 Calls `org-timestamp-down' or `org-priority-down', or `org-next-item'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12053 depending on context. See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12054 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12055 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12056 ((org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12057 (call-interactively (if org-edit-timestamp-down-means-later
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12058 'org-timestamp-up 'org-timestamp-down)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12059 ((org-on-heading-p) (call-interactively 'org-priority-down))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12060 ((org-clocktable-try-shift 'down arg))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12061 (t (call-interactively 'org-next-item))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12062
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12063 (defun org-shiftright (&optional arg)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12064 "Next TODO keyword or timestamp one day later, depending on context."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12065 (interactive "P")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12066 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12067 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12068 ((org-on-heading-p) (org-call-with-arg 'org-todo 'right))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12069 ((org-at-item-p) (org-call-with-arg 'org-cycle-list-bullet nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12070 ((org-at-property-p) (call-interactively 'org-property-next-allowed-value))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12071 ((org-clocktable-try-shift 'right arg))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12072 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12073
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12074 (defun org-shiftleft (&optional arg)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12075 "Previous TODO keyword or timestamp one day earlier, depending on context."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12076 (interactive "P")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12077 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12078 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12079 ((org-on-heading-p) (org-call-with-arg 'org-todo 'left))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12080 ((org-at-item-p) (org-call-with-arg 'org-cycle-list-bullet 'previous))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12081 ((org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12082 (call-interactively 'org-property-previous-allowed-value))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12083 ((org-clocktable-try-shift 'left arg))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12084 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12085
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12086 (defun org-shiftcontrolright ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12087 "Switch to next TODO set."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12088 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12089 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12090 ((org-on-heading-p) (org-call-with-arg 'org-todo 'nextset))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12091 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12092
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12093 (defun org-shiftcontrolleft ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12094 "Switch to previous TODO set."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12095 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12096 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12097 ((org-on-heading-p) (org-call-with-arg 'org-todo 'previousset))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12098 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12099
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12100 (defun org-ctrl-c-ret ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12101 "Call `org-table-hline-and-move' or `org-insert-heading' dep. on context."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12102 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12103 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12104 ((org-at-table-p) (call-interactively 'org-table-hline-and-move))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12105 (t (call-interactively 'org-insert-heading))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12106
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12107 (defun org-copy-special ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12108 "Copy region in table or copy current subtree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12109 Calls `org-table-copy' or `org-copy-subtree', depending on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12110 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12111 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12112 (call-interactively
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12113 (if (org-at-table-p) 'org-table-copy-region 'org-copy-subtree)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12114
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12115 (defun org-cut-special ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12116 "Cut region in table or cut current subtree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12117 Calls `org-table-copy' or `org-cut-subtree', depending on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12118 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12119 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12120 (call-interactively
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12121 (if (org-at-table-p) 'org-table-cut-region 'org-cut-subtree)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12122
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12123 (defun org-paste-special (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12124 "Paste rectangular region into table, or past subtree relative to level.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12125 Calls `org-table-paste-rectangle' or `org-paste-subtree', depending on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12126 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12127 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12128 (if (org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12129 (org-table-paste-rectangle)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12130 (org-paste-subtree arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12131
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12132 (defun org-ctrl-c-ctrl-c (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12133 "Set tags in headline, or update according to changed information at point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12134
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12135 This command does many different things, depending on context:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12136
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12137 - If the cursor is in a headline, prompt for tags and insert them
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12138 into the current line, aligned to `org-tags-column'. When called
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12139 with prefix arg, realign all tags in the current buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12140
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12141 - If the cursor is in one of the special #+KEYWORD lines, this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12142 triggers scanning the buffer for these lines and updating the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12143 information.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12144
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12145 - If the cursor is inside a table, realign the table. This command
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12146 works even if the automatic table editor has been turned off.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12147
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12148 - If the cursor is on a #+TBLFM line, re-apply the formulas to
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12149 the entire table.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12150
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12151 - If the cursor is a the beginning of a dynamic block, update it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12152
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12153 - If the cursor is inside a table created by the table.el package,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12154 activate that table.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12155
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12156 - If the current buffer is a remember buffer, close note and file it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12157 with a prefix argument, file it without further interaction to the default
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12158 location.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12159
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12160 - If the cursor is on a <<<target>>>, update radio targets and corresponding
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12161 links in this buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12162
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12163 - If the cursor is on a numbered item in a plain list, renumber the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12164 ordered list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12165
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12166 - If the cursor is on a checkbox, toggle it."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12167 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12168 (let ((org-enable-table-editor t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12169 (cond
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12170 ((or (and (boundp 'org-clock-overlays) org-clock-overlays)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12171 org-occur-highlights
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12172 org-latex-fragment-image-overlays)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12173 (and (boundp 'org-clock-overlays) (org-remove-clock-overlays))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12174 (org-remove-occur-highlights)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12175 (org-remove-latex-fragment-image-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12176 (message "Temporary highlights/overlays removed from current buffer"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12177 ((and (local-variable-p 'org-finish-function (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12178 (fboundp org-finish-function))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12179 (funcall org-finish-function))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12180 ((org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12181 (call-interactively 'org-property-action))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12182 ((org-on-target-p) (call-interactively 'org-update-radio-target-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12183 ((org-on-heading-p) (call-interactively 'org-set-tags))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12184 ((org-at-table.el-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12185 (require 'table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12186 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12187 (re-search-forward "|" (save-excursion (end-of-line 2) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12188 (call-interactively 'table-recognize-table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12189 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12190 (org-table-maybe-eval-formula)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12191 (if arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12192 (call-interactively 'org-table-recalculate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12193 (org-table-maybe-recalculate-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12194 (call-interactively 'org-table-align))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12195 ((org-at-item-checkbox-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12196 (call-interactively 'org-toggle-checkbox))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12197 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12198 (call-interactively 'org-maybe-renumber-ordered-list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12199 ((save-excursion (beginning-of-line 1) (looking-at "#\\+BEGIN:"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12200 ;; Dynamic block
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12201 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12202 (org-update-dblock))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12203 ((save-excursion (beginning-of-line 1) (looking-at "#\\+\\([A-Z]+\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12204 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12205 ((equal (match-string 1) "TBLFM")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12206 ;; Recalculate the table before this line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12207 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12208 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12209 (skip-chars-backward " \r\n\t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12210 (if (org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12211 (org-call-with-arg 'org-table-recalculate t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12212 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12213 (call-interactively 'org-mode-restart))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12214 (t (error "C-c C-c can do nothing useful at this location.")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12215
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12216 (defun org-mode-restart ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12217 "Restart Org-mode, to scan again for special lines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12218 Also updates the keyword regular expressions."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12219 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12220 (let ((org-inhibit-startup t)) (org-mode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12221 (message "Org-mode restarted to refresh keyword and special line setup"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12222
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12223 (defun org-kill-note-or-show-branches ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12224 "If this is a Note buffer, abort storing the note. Else call `show-branches'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12225 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12226 (if (not org-finish-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12227 (call-interactively 'show-branches)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12228 (let ((org-note-abort t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12229 (funcall org-finish-function))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12230
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12231 (defun org-return (&optional indent)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12232 "Goto next table row or insert a newline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12233 Calls `org-table-next-row' or `newline', depending on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12234 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12235 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12236 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12237 ((bobp) (if indent (newline-and-indent) (newline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12238 ((and (org-at-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12239 (looking-at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12240 (org-re "\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12241 (org-show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12242 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12243 (newline))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12244 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12245 (org-table-justify-field-maybe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12246 (call-interactively 'org-table-next-row))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12247 (t (if indent (newline-and-indent) (newline)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12248
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12249 (defun org-return-indent ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12250 "Goto next table row or insert a newline and indent.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12251 Calls `org-table-next-row' or `newline-and-indent', depending on
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12252 context. See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12253 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12254 (org-return t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12255
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12256 (defun org-ctrl-c-star ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12257 "Compute table, or change heading status of lines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12258 Calls `org-table-recalculate' or `org-toggle-region-headlines',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12259 depending on context. This will also turn a plain list item or a normal
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12260 line into a subheading."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12261 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12262 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12263 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12264 (call-interactively 'org-table-recalculate))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12265 ((org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12266 ;; Convert all lines in region to list items
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12267 (call-interactively 'org-toggle-region-headings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12268 ((org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12269 (org-toggle-region-headings (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12270 (min (1+ (point-at-eol)) (point-max))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12271 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12272 ;; Convert to heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12273 (let ((level (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12274 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12275 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12276 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12277 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12278 (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12279 (error 0))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12280 (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12281 (concat (make-string (org-get-valid-level level 1) ?*) " ") t t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12282 (t (org-toggle-region-headings (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12283 (min (1+ (point-at-eol)) (point-max))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12284
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12285 (defun org-ctrl-c-minus ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12286 "Insert separator line in table or modify bullet status of line.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12287 Also turns a plain line or a region of lines into list items.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12288 Calls `org-table-insert-hline', `org-toggle-region-items', or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12289 `org-cycle-list-bullet', depending on context."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12290 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12291 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12292 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12293 (call-interactively 'org-table-insert-hline))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12294 ((org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12295 ;; Convert to item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12296 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12297 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12298 (if (looking-at "\\*+ ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12299 (replace-match (concat (make-string (- (match-end 0) (point) 1) ?\ ) "- ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12300 ((org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12301 ;; Convert all lines in region to list items
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12302 (call-interactively 'org-toggle-region-items))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12303 ((org-in-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12304 (call-interactively 'org-cycle-list-bullet))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12305 (t (org-toggle-region-items (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12306 (min (1+ (point-at-eol)) (point-max))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12307
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12308 (defun org-toggle-region-items (beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12309 "Convert all lines in region to list items.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12310 If the first line is already an item, convert all list items in the region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12311 to normal lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12312 (interactive "r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12313 (let (l2 l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12314 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12315 (goto-char end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12316 (setq l2 (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12317 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12318 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12319 (setq l (1- (org-current-line)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12320 (if (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12321 ;; We already have items, de-itemize
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12322 (while (< (setq l (1+ l)) l2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12323 (when (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12324 (goto-char (match-beginning 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12325 (delete-region (match-beginning 2) (match-end 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12326 (and (looking-at "[ \t]+") (replace-match "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12327 (beginning-of-line 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12328 (while (< (setq l (1+ l)) l2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12329 (unless (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12330 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12331 (replace-match "\\1- \\2")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12332 (beginning-of-line 2))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12333
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12334 (defun org-toggle-region-headings (beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12335 "Convert all lines in region to list items.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12336 If the first line is already an item, convert all list items in the region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12337 to normal lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12338 (interactive "r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12339 (let (l2 l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12340 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12341 (goto-char end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12342 (setq l2 (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12343 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12344 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12345 (setq l (1- (org-current-line)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12346 (if (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12347 ;; We already have headlines, de-star them
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12348 (while (< (setq l (1+ l)) l2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12349 (when (org-on-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12350 (and (looking-at outline-regexp) (replace-match "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12351 (beginning-of-line 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12352 (let* ((stars (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12353 (re-search-backward org-complex-heading-regexp nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12354 (or (match-string 1) "*")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12355 (add-stars (if org-odd-levels-only "**" "*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12356 (rpl (concat stars add-stars " \\2")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12357 (while (< (setq l (1+ l)) l2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12358 (unless (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12359 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12360 (replace-match rpl)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12361 (beginning-of-line 2)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12362
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12363 (defun org-meta-return (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12364 "Insert a new heading or wrap a region in a table.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12365 Calls `org-insert-heading' or `org-table-wrap-region', depending on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12366 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12367 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12368 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12369 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12370 (call-interactively 'org-table-wrap-region))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12371 (t (call-interactively 'org-insert-heading))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12372
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12373 ;;; Menu entries
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12374
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12375 ;; Define the Org-mode menus
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12376 (easy-menu-define org-tbl-menu org-mode-map "Tbl menu"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12377 '("Tbl"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12378 ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p)]
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12379 ["Next Field" org-cycle (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12380 ["Previous Field" org-shifttab (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12381 ["Next Row" org-return (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12382 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12383 ["Blank Field" org-table-blank-field (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12384 ["Edit Field" org-table-edit-field (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12385 ["Copy Field from Above" org-table-copy-down (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12386 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12387 ("Column"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12388 ["Move Column Left" org-metaleft (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12389 ["Move Column Right" org-metaright (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12390 ["Delete Column" org-shiftmetaleft (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12391 ["Insert Column" org-shiftmetaright (org-at-table-p)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12392 ("Row"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12393 ["Move Row Up" org-metaup (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12394 ["Move Row Down" org-metadown (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12395 ["Delete Row" org-shiftmetaup (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12396 ["Insert Row" org-shiftmetadown (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12397 ["Sort lines in region" org-table-sort-lines (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12398 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12399 ["Insert Hline" org-ctrl-c-minus (org-at-table-p)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12400 ("Rectangle"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12401 ["Copy Rectangle" org-copy-special (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12402 ["Cut Rectangle" org-cut-special (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12403 ["Paste Rectangle" org-paste-special (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12404 ["Fill Rectangle" org-table-wrap-region (org-at-table-p)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12405 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12406 ("Calculate"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12407 ["Set Column Formula" org-table-eval-formula (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12408 ["Set Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12409 ["Edit Formulas" org-table-edit-formulas (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12410 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12411 ["Recalculate line" org-table-recalculate (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12412 ["Recalculate all" (lambda () (interactive) (org-table-recalculate '(4))) :active (org-at-table-p) :keys "C-u C-c *"]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12413 ["Iterate all" (lambda () (interactive) (org-table-recalculate '(16))) :active (org-at-table-p) :keys "C-u C-u C-c *"]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12414 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12415 ["Toggle Recalculate Mark" org-table-rotate-recalc-marks (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12416 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12417 ["Sum Column/Rectangle" org-table-sum
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12418 (or (org-at-table-p) (org-region-active-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12419 ["Which Column?" org-table-current-column (org-at-table-p)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12420 ["Debug Formulas"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12421 org-table-toggle-formula-debugger
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12422 :style toggle :selected (org-bound-and-true-p org-table-formula-debug)]
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12423 ["Show Col/Row Numbers"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12424 org-table-toggle-coordinate-overlays
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12425 :style toggle
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12426 :selected (org-bound-and-true-p org-table-overlay-coordinates)]
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12427 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12428 ["Create" org-table-create (and (not (org-at-table-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12429 org-enable-table-editor)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12430 ["Convert Region" org-table-convert-region (not (org-at-table-p 'any))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12431 ["Import from File" org-table-import (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12432 ["Export to File" org-table-export (org-at-table-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12433 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12434 ["Create/Convert from/to table.el" org-table-create-with-table.el t]))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12435
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12436 (easy-menu-define org-org-menu org-mode-map "Org menu"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12437 '("Org"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12438 ("Show/Hide"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12439 ["Cycle Visibility" org-cycle :active (or (bobp) (outline-on-heading-p))]
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12440 ["Cycle Global Visibility" org-shifttab :active (not (org-at-table-p))]
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12441 ["Sparse Tree..." org-sparse-tree t]
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12442 ["Reveal Context" org-reveal t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12443 ["Show All" show-all t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12444 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12445 ["Subtree to indirect buffer" org-tree-to-indirect-buffer t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12446 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12447 ["New Heading" org-insert-heading t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12448 ("Navigate Headings"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12449 ["Up" outline-up-heading t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12450 ["Next" outline-next-visible-heading t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12451 ["Previous" outline-previous-visible-heading t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12452 ["Next Same Level" outline-forward-same-level t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12453 ["Previous Same Level" outline-backward-same-level t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12454 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12455 ["Jump" org-goto t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12456 ("Edit Structure"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12457 ["Move Subtree Up" org-shiftmetaup (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12458 ["Move Subtree Down" org-shiftmetadown (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12459 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12460 ["Copy Subtree" org-copy-special (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12461 ["Cut Subtree" org-cut-special (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12462 ["Paste Subtree" org-paste-special (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12463 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12464 ["Promote Heading" org-metaleft (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12465 ["Promote Subtree" org-shiftmetaleft (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12466 ["Demote Heading" org-metaright (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12467 ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12468 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12469 ["Sort Region/Children" org-sort (not (org-at-table-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12470 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12471 ["Convert to odd levels" org-convert-to-odd-levels t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12472 ["Convert to odd/even levels" org-convert-to-oddeven-levels t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12473 ("Editing"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12474 ["Emphasis..." org-emphasize t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12475 ("Archive"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12476 ["Toggle ARCHIVE tag" org-toggle-archive-tag t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12477 ; ["Check and Tag Children" (org-toggle-archive-tag (4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12478 ; :active t :keys "C-u C-c C-x C-a"]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12479 ["Sparse trees open ARCHIVE trees"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12480 (setq org-sparse-tree-open-archived-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12481 (not org-sparse-tree-open-archived-trees))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12482 :style toggle :selected org-sparse-tree-open-archived-trees]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12483 ["Cycling opens ARCHIVE trees"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12484 (setq org-cycle-open-archived-trees (not org-cycle-open-archived-trees))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12485 :style toggle :selected org-cycle-open-archived-trees]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12486 ["Agenda includes ARCHIVE trees"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12487 (setq org-agenda-skip-archived-trees (not org-agenda-skip-archived-trees))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12488 :style toggle :selected (not org-agenda-skip-archived-trees)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12489 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12490 ["Move Subtree to Archive" org-advertized-archive-subtree t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12491 ; ["Check and Move Children" (org-archive-subtree '(4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12492 ; :active t :keys "C-u C-c C-x C-s"]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12493 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12494 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12495 ("TODO Lists"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12496 ["TODO/DONE/-" org-todo t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12497 ("Select keyword"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12498 ["Next keyword" org-shiftright (org-on-heading-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12499 ["Previous keyword" org-shiftleft (org-on-heading-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12500 ["Complete Keyword" org-complete (assq :todo-keyword (org-context))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12501 ["Next keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12502 ["Previous keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12503 ["Show TODO Tree" org-show-todo-tree t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12504 ["Global TODO list" org-todo-list t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12505 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12506 ["Set Priority" org-priority t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12507 ["Priority Up" org-shiftup t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12508 ["Priority Down" org-shiftdown t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12509 ("TAGS and Properties"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12510 ["Set Tags" 'org-ctrl-c-ctrl-c (org-at-heading-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12511 ["Change tag in region" 'org-change-tag-in-region (org-region-active-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12512 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12513 ["Set property" 'org-set-property t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12514 ["Column view of properties" org-columns t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12515 ["Insert Column View DBlock" org-insert-columns-dblock t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12516 ("Dates and Scheduling"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12517 ["Timestamp" org-time-stamp t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12518 ["Timestamp (inactive)" org-time-stamp-inactive t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12519 ("Change Date"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12520 ["1 Day Later" org-shiftright t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12521 ["1 Day Earlier" org-shiftleft t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12522 ["1 ... Later" org-shiftup t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12523 ["1 ... Earlier" org-shiftdown t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12524 ["Compute Time Range" org-evaluate-time-range t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12525 ["Schedule Item" org-schedule t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12526 ["Deadline" org-deadline t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12527 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12528 ["Custom time format" org-toggle-time-stamp-overlays
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12529 :style radio :selected org-display-custom-times]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12530 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12531 ["Goto Calendar" org-goto-calendar t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12532 ["Date from Calendar" org-date-from-calendar t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12533 ("Logging work"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12534 ["Clock in" org-clock-in t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12535 ["Clock out" org-clock-out t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12536 ["Clock cancel" org-clock-cancel t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12537 ["Goto running clock" org-clock-goto t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12538 ["Display times" org-clock-display t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12539 ["Create clock table" org-clock-report t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12540 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12541 ["Record DONE time"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12542 (progn (setq org-log-done (not org-log-done))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12543 (message "Switching to %s will %s record a timestamp"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12544 (car org-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12545 (if org-log-done "automatically" "not")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12546 :style toggle :selected org-log-done])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12547 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12548 ["Agenda Command..." org-agenda t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12549 ["Set Restriction Lock" org-agenda-set-restriction-lock t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12550 ("File List for Agenda")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12551 ("Special views current file"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12552 ["TODO Tree" org-show-todo-tree t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12553 ["Check Deadlines" org-check-deadlines t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12554 ["Timeline" org-timeline t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12555 ["Tags Tree" org-tags-sparse-tree t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12556 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12557 ("Hyperlinks"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12558 ["Store Link (Global)" org-store-link t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12559 ["Insert Link" org-insert-link t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12560 ["Follow Link" org-open-at-point t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12561 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12562 ["Next link" org-next-link t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12563 ["Previous link" org-previous-link t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12564 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12565 ["Descriptive Links"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12566 (progn (org-add-to-invisibility-spec '(org-link)) (org-restart-font-lock))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12567 :style radio
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12568 :selected (member '(org-link) buffer-invisibility-spec)]
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12569 ["Literal Links"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12570 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12571 (org-remove-from-invisibility-spec '(org-link)) (org-restart-font-lock))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12572 :style radio
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12573 :selected (not (member '(org-link) buffer-invisibility-spec))])
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12574 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12575 ["Export/Publish..." org-export t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12576 ("LaTeX"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12577 ["Org CDLaTeX mode" org-cdlatex-mode :style toggle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12578 :selected org-cdlatex-mode]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12579 ["Insert Environment" cdlatex-environment (fboundp 'cdlatex-environment)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12580 ["Insert math symbol" cdlatex-math-symbol (fboundp 'cdlatex-math-symbol)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12581 ["Modify math symbol" org-cdlatex-math-modify
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12582 (org-inside-LaTeX-fragment-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12583 ["Export LaTeX fragments as images"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12584 (if (featurep 'org-exp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12585 (setq org-export-with-LaTeX-fragments
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12586 (not org-export-with-LaTeX-fragments))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12587 (require 'org-exp))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12588 :style toggle :selected (and (boundp 'org-export-with-LaTeX-fragments)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12589 org-export-with-LaTeX-fragments)])
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12590 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12591 ("Documentation"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12592 ["Show Version" org-version t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12593 ["Info Documentation" org-info t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12594 ("Customize"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12595 ["Browse Org Group" org-customize t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12596 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12597 ["Expand This Menu" org-create-customize-menu
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12598 (fboundp 'customize-menu-create)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12599 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12600 ["Refresh setup" org-mode-restart t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12601 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12602
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12603 (defun org-info (&optional node)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12604 "Read documentation for Org-mode in the info system.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12605 With optional NODE, go directly to that node."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12606 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12607 (info (format "(org)%s" (or node ""))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12608
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12609 (defun org-install-agenda-files-menu ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12610 (let ((bl (buffer-list)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12611 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12612 (while bl
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12613 (set-buffer (pop bl))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12614 (if (org-mode-p) (setq bl nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12615 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12616 (easy-menu-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12617 '("Org") "File List for Agenda"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12618 (append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12619 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12620 ["Edit File List" (org-edit-agenda-file-list) t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12621 ["Add/Move Current File to Front of List" org-agenda-file-to-front t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12622 ["Remove Current File from List" org-remove-file t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12623 ["Cycle through agenda files" org-cycle-agenda-files t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12624 ["Occur in all agenda files" org-occur-in-agenda-files t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12625 "--")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12626 (mapcar 'org-file-menu-entry (org-agenda-files t))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12627
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12628 ;;;; Documentation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12629
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12630 (defun org-require-autoloaded-modules ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12631 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12632 (mapc 'require
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12633 '(org-agenda org-archive org-clock org-colview
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12634 org-exp org-export-latex org-publish
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12635 org-remember org-table)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12636
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12637 (defun org-customize ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12638 "Call the customize function with org as argument."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12639 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12640 (org-load-modules-maybe)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12641 (org-require-autoloaded-modules)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12642 (customize-browse 'org))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12643
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12644 (defun org-create-customize-menu ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12645 "Create a full customization menu for Org-mode, insert it into the menu."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12646 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12647 (org-load-modules-maybe)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12648 (org-require-autoloaded-modules)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12649 (if (fboundp 'customize-menu-create)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12650 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12651 (easy-menu-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12652 '("Org") "Customize"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12653 `(["Browse Org group" org-customize t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12654 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12655 ,(customize-menu-create 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12656 ["Set" Custom-set t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12657 ["Save" Custom-save t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12658 ["Reset to Current" Custom-reset-current t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12659 ["Reset to Saved" Custom-reset-saved t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12660 ["Reset to Standard Settings" Custom-reset-standard t]))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12661 (message "\"Org\"-menu now contains full customization menu"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12662 (error "Cannot expand menu (outdated version of cus-edit.el)")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12663
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12664 ;;;; Miscellaneous stuff
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12665
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12666 ;;; Generally useful functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12667
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12668 (defun org-plist-delete (plist property)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12669 "Delete PROPERTY from PLIST.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12670 This is in contrast to merely setting it to 0."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12671 (let (p)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12672 (while plist
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12673 (if (not (eq property (car plist)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12674 (setq p (plist-put p (car plist) (nth 1 plist))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12675 (setq plist (cddr plist)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12676 p))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12677
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12678 (defun org-force-self-insert (N)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12679 "Needed to enforce self-insert under remapping."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12680 (interactive "p")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12681 (self-insert-command N))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12682
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12683 (defun org-string-width (s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12684 "Compute width of string, ignoring invisible characters.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12685 This ignores character with invisibility property `org-link', and also
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12686 characters with property `org-cwidth', because these will become invisible
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12687 upon the next fontification round."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12688 (let (b l)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12689 (when (or (eq t buffer-invisibility-spec)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12690 (assq 'org-link buffer-invisibility-spec))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12691 (while (setq b (text-property-any 0 (length s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12692 'invisible 'org-link s))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12693 (setq s (concat (substring s 0 b)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12694 (substring s (or (next-single-property-change
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12695 b 'invisible s) (length s)))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12696 (while (setq b (text-property-any 0 (length s) 'org-cwidth t s))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12697 (setq s (concat (substring s 0 b)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12698 (substring s (or (next-single-property-change
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12699 b 'org-cwidth s) (length s))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12700 (setq l (string-width s) b -1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12701 (while (setq b (text-property-any (1+ b) (length s) 'org-dwidth t s))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12702 (setq l (- l (get-text-property b 'org-dwidth-n s))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12703 l))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12704
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12705
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12706 (defun org-trim (s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12707 "Remove whitespace at beginning and end of string."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12708 (if (string-match "\\`[ \t\n\r]+" s) (setq s (replace-match "" t t s)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12709 (if (string-match "[ \t\n\r]+\\'" s) (setq s (replace-match "" t t s)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12710 s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12711
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12712 (defun org-wrap (string &optional width lines)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12713 "Wrap string to either a number of lines, or a width in characters.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12714 If WIDTH is non-nil, the string is wrapped to that width, however many lines
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12715 that costs. If there is a word longer than WIDTH, the text is actually
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12716 wrapped to the length of that word.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12717 IF WIDTH is nil and LINES is non-nil, the string is forced into at most that
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12718 many lines, whatever width that takes.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12719 The return value is a list of lines, without newlines at the end."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12720 (let* ((words (org-split-string string "[ \t\n]+"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12721 (maxword (apply 'max (mapcar 'org-string-width words)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12722 w ll)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12723 (cond (width
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12724 (org-do-wrap words (max maxword width)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12725 (lines
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12726 (setq w maxword)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12727 (setq ll (org-do-wrap words maxword))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12728 (if (<= (length ll) lines)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12729 ll
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12730 (setq ll words)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12731 (while (> (length ll) lines)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12732 (setq w (1+ w))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12733 (setq ll (org-do-wrap words w)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12734 ll))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12735 (t (error "Cannot wrap this")))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12736
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12737 (defun org-do-wrap (words width)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12738 "Create lines of maximum width WIDTH (in characters) from word list WORDS."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12739 (let (lines line)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12740 (while words
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12741 (setq line (pop words))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12742 (while (and words (< (+ (length line) (length (car words))) width))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12743 (setq line (concat line " " (pop words))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12744 (setq lines (push line lines)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12745 (nreverse lines)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12746
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12747 (defun org-split-string (string &optional separators)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12748 "Splits STRING into substrings at SEPARATORS.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12749 No empty strings are returned if there are matches at the beginning
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12750 and end of string."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12751 (let ((rexp (or separators "[ \f\t\n\r\v]+"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12752 (start 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12753 notfirst
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12754 (list nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12755 (while (and (string-match rexp string
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12756 (if (and notfirst
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12757 (= start (match-beginning 0))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12758 (< start (length string)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12759 (1+ start) start))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12760 (< (match-beginning 0) (length string)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12761 (setq notfirst t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12762 (or (eq (match-beginning 0) 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12763 (and (eq (match-beginning 0) (match-end 0))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12764 (eq (match-beginning 0) start))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12765 (setq list
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12766 (cons (substring string start (match-beginning 0))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12767 list)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12768 (setq start (match-end 0)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12769 (or (eq start (length string))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12770 (setq list
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12771 (cons (substring string start)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12772 list)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12773 (nreverse list)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12774
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12775 (defun org-context ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12776 "Return a list of contexts of the current cursor position.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12777 If several contexts apply, all are returned.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12778 Each context entry is a list with a symbol naming the context, and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12779 two positions indicating start and end of the context. Possible
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12780 contexts are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12781
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12782 :headline anywhere in a headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12783 :headline-stars on the leading stars in a headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12784 :todo-keyword on a TODO keyword (including DONE) in a headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12785 :tags on the TAGS in a headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12786 :priority on the priority cookie in a headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12787 :item on the first line of a plain list item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12788 :item-bullet on the bullet/number of a plain list item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12789 :checkbox on the checkbox in a plain list item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12790 :table in an org-mode table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12791 :table-special on a special filed in a table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12792 :table-table in a table.el table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12793 :link on a hyperlink
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12794 :keyword on a keyword: SCHEDULED, DEADLINE, CLOSE,COMMENT, QUOTE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12795 :target on a <<target>>
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12796 :radio-target on a <<<radio-target>>>
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12797 :latex-fragment on a LaTeX fragment
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12798 :latex-preview on a LaTeX fragment with overlayed preview image
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12799
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12800 This function expects the position to be visible because it uses font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12801 faces as a help to recognize the following contexts: :table-special, :link,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12802 and :keyword."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12803 (let* ((f (get-text-property (point) 'face))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12804 (faces (if (listp f) f (list f)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12805 (p (point)) clist o)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12806 ;; First the large context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12807 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12808 ((org-on-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12809 (push (list :headline (point-at-bol) (point-at-eol)) clist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12810 (when (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12811 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12812 (looking-at org-todo-line-tags-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12813 (push (org-point-in-group p 1 :headline-stars) clist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12814 (push (org-point-in-group p 2 :todo-keyword) clist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12815 (push (org-point-in-group p 4 :tags) clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12816 (goto-char p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12817 (skip-chars-backward "^[\n\r \t") (or (eobp) (backward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12818 (if (looking-at "\\[#[A-Z0-9]\\]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12819 (push (org-point-in-group p 0 :priority) clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12820
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12821 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12822 (push (org-point-in-group p 2 :item-bullet) clist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12823 (push (list :item (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12824 (save-excursion (org-end-of-item) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12825 clist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12826 (and (org-at-item-checkbox-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12827 (push (org-point-in-group p 0 :checkbox) clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12828
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12829 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12830 (push (list :table (org-table-begin) (org-table-end)) clist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12831 (if (memq 'org-formula faces)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12832 (push (list :table-special
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12833 (previous-single-property-change p 'face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12834 (next-single-property-change p 'face)) clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12835 ((org-at-table-p 'any)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12836 (push (list :table-table) clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12837 (goto-char p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12838
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12839 ;; Now the small context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12840 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12841 ((org-at-timestamp-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12842 (push (org-point-in-group p 0 :timestamp) clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12843 ((memq 'org-link faces)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12844 (push (list :link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12845 (previous-single-property-change p 'face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12846 (next-single-property-change p 'face)) clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12847 ((memq 'org-special-keyword faces)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12848 (push (list :keyword
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12849 (previous-single-property-change p 'face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12850 (next-single-property-change p 'face)) clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12851 ((org-on-target-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12852 (push (org-point-in-group p 0 :target) clist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12853 (goto-char (1- (match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12854 (if (looking-at org-radio-target-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12855 (push (org-point-in-group p 0 :radio-target) clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12856 (goto-char p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12857 ((setq o (car (delq nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12858 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12859 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12860 (if (memq x org-latex-fragment-image-overlays) x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12861 (org-overlays-at (point))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12862 (push (list :latex-fragment
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12863 (org-overlay-start o) (org-overlay-end o)) clist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12864 (push (list :latex-preview
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12865 (org-overlay-start o) (org-overlay-end o)) clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12866 ((org-inside-LaTeX-fragment-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12867 ;; FIXME: positions wrong.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12868 (push (list :latex-fragment (point) (point)) clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12869
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12870 (setq clist (nreverse (delq nil clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12871 clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12872
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12873 ;; FIXME: Compare with at-regexp-p Do we need both?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12874 (defun org-in-regexp (re &optional nlines visually)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12875 "Check if point is inside a match of regexp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12876 Normally only the current line is checked, but you can include NLINES extra
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12877 lines both before and after point into the search.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12878 If VISUALLY is set, require that the cursor is not after the match but
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12879 really on, so that the block visually is on the match."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12880 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12881 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12882 (eol (point-at-eol (+ 1 (or nlines 0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12883 (inc (if visually 1 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12884 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12885 (beginning-of-line (- 1 (or nlines 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12886 (while (re-search-forward re eol t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12887 (if (and (<= (match-beginning 0) pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12888 (>= (+ inc (match-end 0)) pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12889 (throw 'exit (cons (match-beginning 0) (match-end 0)))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12890
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12891 (defun org-at-regexp-p (regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12892 "Is point inside a match of REGEXP in the current line?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12893 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12894 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12895 (let ((pos (point)) (end (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12896 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12897 (while (re-search-forward regexp end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12898 (if (and (<= (match-beginning 0) pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12899 (>= (match-end 0) pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12900 (throw 'exit t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12901 nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12902
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12903 (defun org-occur-in-agenda-files (regexp &optional nlines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12904 "Call `multi-occur' with buffers for all agenda files."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12905 (interactive "sOrg-files matching: \np")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12906 (let* ((files (org-agenda-files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12907 (tnames (mapcar 'file-truename files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12908 (extra org-agenda-text-search-extra-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12909 f)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12910 (when (eq (car extra) 'agenda-archives)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12911 (setq extra (cdr extra))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12912 (setq files (org-add-archive-files files)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12913 (while (setq f (pop extra))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12914 (unless (member (file-truename f) tnames)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12915 (add-to-list 'files f 'append)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12916 (add-to-list 'tnames (file-truename f) 'append)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12917 (multi-occur
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12918 (mapcar (lambda (x) (or (get-file-buffer x) (find-file-noselect x))) files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12919 regexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12920
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12921 (if (boundp 'occur-mode-find-occurrence-hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12922 ;; Emacs 23
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12923 (add-hook 'occur-mode-find-occurrence-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12924 (lambda ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12925 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12926 (org-reveal))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12927 ;; Emacs 22
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12928 (defadvice occur-mode-goto-occurrence
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12929 (after org-occur-reveal activate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12930 (and (org-mode-p) (org-reveal)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12931 (defadvice occur-mode-goto-occurrence-other-window
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12932 (after org-occur-reveal activate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12933 (and (org-mode-p) (org-reveal)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12934 (defadvice occur-mode-display-occurrence
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12935 (after org-occur-reveal activate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12936 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12937 (let ((pos (occur-mode-find-occurrence)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12938 (with-current-buffer (marker-buffer pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12939 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12940 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12941 (org-reveal)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12942
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12943 (defun org-uniquify (list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12944 "Remove duplicate elements from LIST."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12945 (let (res)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12946 (mapc (lambda (x) (add-to-list 'res x 'append)) list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12947 res))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12948
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12949 (defun org-delete-all (elts list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12950 "Remove all elements in ELTS from LIST."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12951 (while elts
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12952 (setq list (delete (pop elts) list)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12953 list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12954
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12955 (defun org-back-over-empty-lines ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12956 "Move backwards over witespace, to the beginning of the first empty line.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12957 Returns the number of empty lines passed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12958 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12959 (skip-chars-backward " \t\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12960 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12961 (goto-char (min (point) pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12962 (count-lines (point) pos)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12963
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12964 (defun org-skip-whitespace ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12965 (skip-chars-forward " \t\n\r"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12966
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12967 (defun org-point-in-group (point group &optional context)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12968 "Check if POINT is in match-group GROUP.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12969 If CONTEXT is non-nil, return a list with CONTEXT and the boundaries of the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12970 match. If the match group does ot exist or point is not inside it,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12971 return nil."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12972 (and (match-beginning group)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12973 (>= point (match-beginning group))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12974 (<= point (match-end group))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12975 (if context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12976 (list context (match-beginning group) (match-end group))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12977 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12978
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12979 (defun org-switch-to-buffer-other-window (&rest args)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12980 "Switch to buffer in a second window on the current frame.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12981 In particular, do not allow pop-up frames."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12982 (let (pop-up-frames special-display-buffer-names special-display-regexps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12983 special-display-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12984 (apply 'switch-to-buffer-other-window args)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12985
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12986 (defun org-combine-plists (&rest plists)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12987 "Create a single property list from all plists in PLISTS.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12988 The process starts by copying the first list, and then setting properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12989 from the other lists. Settings in the last list are the most significant
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12990 ones and overrule settings in the other lists."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12991 (let ((rtn (copy-sequence (pop plists)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12992 p v ls)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12993 (while plists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12994 (setq ls (pop plists))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12995 (while ls
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12996 (setq p (pop ls) v (pop ls))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12997 (setq rtn (plist-put rtn p v))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12998 rtn))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12999
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13000 (defun org-move-line-down (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13001 "Move the current line down. With prefix argument, move it past ARG lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13002 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13003 (let ((col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13004 beg end pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13005 (beginning-of-line 1) (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13006 (beginning-of-line 2) (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13007 (beginning-of-line (+ 1 arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13008 (setq pos (move-marker (make-marker) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13009 (insert (delete-and-extract-region beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13010 (goto-char pos)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13011 (org-move-to-column col)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13012
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13013 (defun org-move-line-up (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13014 "Move the current line up. With prefix argument, move it past ARG lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13015 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13016 (let ((col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13017 beg end pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13018 (beginning-of-line 1) (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13019 (beginning-of-line 2) (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13020 (beginning-of-line (- arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13021 (setq pos (move-marker (make-marker) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13022 (insert (delete-and-extract-region beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13023 (goto-char pos)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13024 (org-move-to-column col)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13025
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13026 (defun org-replace-escapes (string table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13027 "Replace %-escapes in STRING with values in TABLE.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13028 TABLE is an association list with keys like \"%a\" and string values.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13029 The sequences in STRING may contain normal field width and padding information,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13030 for example \"%-5s\". Replacements happen in the sequence given by TABLE,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13031 so values can contain further %-escapes if they are define later in TABLE."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13032 (let ((case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13033 e re rpl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13034 (while (setq e (pop table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13035 (setq re (concat "%-?[0-9.]*" (substring (car e) 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13036 (while (string-match re string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13037 (setq rpl (format (concat (substring (match-string 0 string) 0 -1) "s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13038 (cdr e)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13039 (setq string (replace-match rpl t t string))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13040 string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13041
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13042
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13043 (defun org-sublist (list start end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13044 "Return a section of LIST, from START to END.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13045 Counting starts at 1."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13046 (let (rtn (c start))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13047 (setq list (nthcdr (1- start) list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13048 (while (and list (<= c end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13049 (push (pop list) rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13050 (setq c (1+ c)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13051 (nreverse rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13052
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13053 (defun org-find-base-buffer-visiting (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13054 "Like `find-buffer-visiting' but alway return the base buffer and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13055 not an indirect buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13056 (let ((buf (find-buffer-visiting file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13057 (if buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13058 (or (buffer-base-buffer buf) buf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13059 nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13060
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13061 (defun org-image-file-name-regexp ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13062 "Return regexp matching the file names of images."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13063 (if (fboundp 'image-file-name-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13064 (image-file-name-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13065 (let ((image-file-name-extensions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13066 '("png" "jpeg" "jpg" "gif" "tiff" "tif"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13067 "xbm" "xpm" "pbm" "pgm" "ppm")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13068 (concat "\\."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13069 (regexp-opt (nconc (mapcar 'upcase
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13070 image-file-name-extensions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13071 image-file-name-extensions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13072 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13073 "\\'"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13074
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13075 (defun org-file-image-p (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13076 "Return non-nil if FILE is an image."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13077 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13078 (string-match (org-image-file-name-regexp) file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13079
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13080 ;;; Paragraph filling stuff.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13081 ;; We want this to be just right, so use the full arsenal.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13082
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13083 (defun org-indent-line-function ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13084 "Indent line like previous, but further if previous was headline or item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13085 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13086 (let* ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13087 (itemp (org-at-item-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13088 column bpos bcol tpos tcol bullet btype bullet-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13089 ;; Find the previous relevant line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13090 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13091 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13092 ((looking-at "#") (setq column 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13093 ((looking-at "\\*+ ") (setq column 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13094 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13095 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13096 (while (and (not (bobp)) (looking-at "[ \t]*[\n:#|]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13097 (beginning-of-line 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13098 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13099 ((looking-at "\\*+[ \t]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13100 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13101 (setq column (current-column)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13102 ((org-in-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13103 (org-beginning-of-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13104 ; (looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13105 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13106 (setq bpos (match-beginning 1) tpos (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13107 bcol (progn (goto-char bpos) (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13108 tcol (progn (goto-char tpos) (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13109 bullet (match-string 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13110 bullet-type (if (string-match "[0-9]" bullet) "n" bullet))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13111 (if (not itemp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13112 (setq column tcol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13113 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13114 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13115 (if (looking-at "\\S-")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13116 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13117 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13118 (setq bullet (match-string 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13119 btype (if (string-match "[0-9]" bullet) "n" bullet))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13120 (setq column (if (equal btype bullet-type) bcol tcol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13121 (setq column (org-get-indentation)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13122 (t (setq column (org-get-indentation))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13123 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13124 (if (<= (current-column) (current-indentation))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13125 (org-indent-line-to column)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13126 (save-excursion (org-indent-line-to column)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13127 (setq column (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13128 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13129 (if (looking-at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13130 "\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13131 (replace-match (concat "\\1" (format org-property-format
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13132 (match-string 2) (match-string 3)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13133 t nil))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13134 (org-move-to-column column)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13135
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13136 (defun org-set-autofill-regexps ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13137 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13138 ;; In the paragraph separator we include headlines, because filling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13139 ;; text in a line directly attached to a headline would otherwise
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13140 ;; fill the headline as well.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13141 (org-set-local 'comment-start-skip "^#+[ \t]*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13142 (org-set-local 'paragraph-separate "\f\\|\\*+ \\|[ ]*$\\|[ \t]*[:|]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13143 ;; The paragraph starter includes hand-formatted lists.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13144 (org-set-local 'paragraph-start
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13145 "\f\\|[ ]*$\\|\\*+ \\|\f\\|[ \t]*\\([-+*][ \t]+\\|[0-9]+[.)][ \t]+\\)\\|[ \t]*[:|]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13146 ;; Inhibit auto-fill for headers, tables and fixed-width lines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13147 ;; But only if the user has not turned off tables or fixed-width regions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13148 (org-set-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13149 'auto-fill-inhibit-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13150 (concat "\\*+ \\|#\\+"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13151 "\\|[ \t]*" org-keyword-time-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13152 (if (or org-enable-table-editor org-enable-fixed-width-editor)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13153 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13154 "\\|[ \t]*["
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13155 (if org-enable-table-editor "|" "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13156 (if org-enable-fixed-width-editor ":" "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13157 "]"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13158 ;; We use our own fill-paragraph function, to make sure that tables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13159 ;; and fixed-width regions are not wrapped. That function will pass
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13160 ;; through to `fill-paragraph' when appropriate.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13161 (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13162 ; Adaptive filling: To get full control, first make sure that
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13163 ;; `adaptive-fill-regexp' never matches. Then install our own matcher.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13164 (org-set-local 'adaptive-fill-regexp "\000")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13165 (org-set-local 'adaptive-fill-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13166 'org-adaptive-fill-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13167 (org-set-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13168 'align-mode-rules-list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13169 '((org-in-buffer-settings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13170 (regexp . "^#\\+[A-Z_]+:\\(\\s-*\\)\\S-+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13171 (modes . '(org-mode))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13172
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13173 (defun org-fill-paragraph (&optional justify)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13174 "Re-align a table, pass through to fill-paragraph if no table."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13175 (let ((table-p (org-at-table-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13176 (table.el-p (org-at-table.el-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13177 (cond ((and (equal (char-after (point-at-bol)) ?*)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13178 (save-excursion (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13179 (looking-at outline-regexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13180 t) ; skip headlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13181 (table.el-p t) ; skip table.el tables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13182 (table-p (org-table-align) t) ; align org-mode tables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13183 (t nil)))) ; call paragraph-fill
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13184
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13185 ;; For reference, this is the default value of adaptive-fill-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13186 ;; "[ \t]*\\([-|#;>*]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13187
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13188 (defun org-adaptive-fill-function ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13189 "Return a fill prefix for org-mode files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13190 In particular, this makes sure hanging paragraphs for hand-formatted lists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13191 work correctly."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13192 (cond ((looking-at "#[ \t]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13193 (match-string 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13194 ((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)] \\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13195 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13196 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13197 (make-string (current-column) ?\ )))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13198 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13199
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13200 ;;; Other stuff.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13201
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13202 (defun org-toggle-fixed-width-section (arg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13203 "Toggle the fixed-width export.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13204 If there is no active region, the QUOTE keyword at the current headline is
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13205 inserted or removed. When present, it causes the text between this headline
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13206 and the next to be exported as fixed-width text, and unmodified.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13207 If there is an active region, this command adds or removes a colon as the
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13208 first character of this line. If the first character of a line is a colon,
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13209 this line is also exported in fixed-width font."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13210 (interactive "P")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13211 (let* ((cc 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13212 (regionp (org-region-active-p))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13213 (beg (if regionp (region-beginning) (point)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13214 (end (if regionp (region-end)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13215 (nlines (or arg (if (and beg end) (count-lines beg end) 1)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13216 (case-fold-search nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13217 (re "[ \t]*\\(:\\)")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13218 off)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13219 (if regionp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13220 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13221 (goto-char beg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13222 (setq cc (current-column))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13223 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13224 (setq off (looking-at re))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13225 (while (> nlines 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13226 (setq nlines (1- nlines))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13227 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13228 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13229 (arg
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13230 (org-move-to-column cc t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13231 (insert ":\n")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13232 (forward-line -1))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13233 ((and off (looking-at re))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13234 (replace-match "" t t nil 1))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13235 ((not off) (org-move-to-column cc t) (insert ":")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13236 (forward-line 1)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13237 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13238 (org-back-to-heading)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13239 (if (looking-at (concat outline-regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13240 "\\( *\\<" org-quote-string "\\>[ \t]*\\)"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13241 (replace-match "" t t nil 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13242 (if (looking-at outline-regexp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13243 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13244 (goto-char (match-end 0))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13245 (insert org-quote-string " "))))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13246
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13247 ;;;; Functions extending outline functionality
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13248
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13249 (defun org-beginning-of-line (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13250 "Go to the beginning of the current line. If that is invisible, continue
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13251 to a visible line beginning. This makes the function of C-a more intuitive.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13252 If this is a headline, and `org-special-ctrl-a/e' is set, ignore tags on the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13253 first attempt, and only move to after the tags when the cursor is already
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13254 beyond the end of the headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13255 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13256 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13257 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13258 (if (bobp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13259 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13260 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13261 (if (org-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13262 (while (and (not (bobp)) (org-invisible-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13263 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13264 (beginning-of-line 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13265 (forward-char 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13266 (when org-special-ctrl-a/e
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13267 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13268 ((and (looking-at org-todo-line-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13269 (= (char-after (match-end 1)) ?\ ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13270 (goto-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13271 (if (eq org-special-ctrl-a/e t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13272 (cond ((> pos (match-beginning 3)) (match-beginning 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13273 ((= pos (point)) (match-beginning 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13274 (t (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13275 (cond ((> pos (point)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13276 ((not (eq last-command this-command)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13277 (t (match-beginning 3))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13278 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13279 (goto-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13280 (if (eq org-special-ctrl-a/e t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13281 (cond ((> pos (match-end 4)) (match-end 4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13282 ((= pos (point)) (match-end 4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13283 (t (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13284 (cond ((> pos (point)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13285 ((not (eq last-command this-command)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13286 (t (match-end 4))))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13287
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13288 (defun org-end-of-line (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13289 "Go to the end of the line.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13290 If this is a headline, and `org-special-ctrl-a/e' is set, ignore tags on the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13291 first attempt, and only move to after the tags when the cursor is already
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13292 beyond the end of the headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13293 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13294 (if (or (not org-special-ctrl-a/e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13295 (not (org-on-heading-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13296 (end-of-line arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13297 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13298 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13299 (if (looking-at (org-re ".*?\\([ \t]*\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13300 (if (eq org-special-ctrl-a/e t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13301 (if (or (< pos (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13302 (= pos (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13303 (goto-char (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13304 (goto-char (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13305 (if (or (< pos (match-end 0)) (not (eq this-command last-command)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13306 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13307 (goto-char (match-beginning 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13308 (end-of-line arg)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13309
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13310 (define-key org-mode-map "\C-a" 'org-beginning-of-line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13311 (define-key org-mode-map "\C-e" 'org-end-of-line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13312
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13313 (defun org-kill-line (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13314 "Kill line, to tags or end of line."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13315 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13316 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13317 ((or (not org-special-ctrl-k)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13318 (bolp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13319 (not (org-on-heading-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13320 (call-interactively 'kill-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13321 ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13322 (kill-region (point) (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13323 (org-set-tags nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13324 (t (kill-region (point) (point-at-eol)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13325
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13326 (define-key org-mode-map "\C-k" 'org-kill-line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13327
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13328 (defun org-invisible-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13329 "Check if point is at a character currently not visible."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13330 ;; Early versions of noutline don't have `outline-invisible-p'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13331 (if (fboundp 'outline-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13332 (outline-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13333 (get-char-property (point) 'invisible)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13334
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13335 (defun org-invisible-p2 ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13336 "Check if point is at a character currently not visible."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13337 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13338 (if (and (eolp) (not (bobp))) (backward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13339 ;; Early versions of noutline don't have `outline-invisible-p'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13340 (if (fboundp 'outline-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13341 (outline-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13342 (get-char-property (point) 'invisible))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13343
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13344 (defalias 'org-back-to-heading 'outline-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13345 (defalias 'org-on-heading-p 'outline-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13346 (defalias 'org-at-heading-p 'outline-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13347 (defun org-at-heading-or-item-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13348 (or (org-on-heading-p) (org-at-item-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13349
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13350 (defun org-on-target-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13351 (or (org-in-regexp org-radio-target-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13352 (org-in-regexp org-target-regexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13353
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13354 (defun org-up-heading-all (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13355 "Move to the heading line of which the present line is a subheading.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13356 This function considers both visible and invisible heading lines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13357 With argument, move up ARG levels."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13358 (if (fboundp 'outline-up-heading-all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13359 (outline-up-heading-all arg) ; emacs 21 version of outline.el
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13360 (outline-up-heading arg t))) ; emacs 22 version of outline.el
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13361
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13362 (defun org-up-heading-safe ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13363 "Move to the heading line of which the present line is a subheading.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13364 This version will not throw an error. It will return the level of the
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13365 headline found, or nil if no higher level is found."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13366 (let ((pos (point)) start-level level
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13367 (re (concat "^" outline-regexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13368 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13369 (outline-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13370 (setq start-level (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13371 (if (equal start-level 1) (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13372 (while (re-search-backward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13373 (setq level (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13374 (if (< level start-level) (throw 'exit level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13375 nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13376
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13377 (defun org-first-sibling-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13378 "Is this heading the first child of its parents?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13379 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13380 (let ((re (concat "^" outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13381 level l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13382 (unless (org-at-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13383 (error "Not at a heading"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13384 (setq level (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13385 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13386 (if (not (re-search-backward re nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13387 t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13388 (setq l (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13389 (< l level)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13390
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13391 (defun org-goto-sibling (&optional previous)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13392 "Goto the next sibling, even if it is invisible.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13393 When PREVIOUS is set, go to the previous sibling instead. Returns t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13394 when a sibling was found. When none is found, return nil and don't
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13395 move point."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13396 (let ((fun (if previous 're-search-backward 're-search-forward))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13397 (pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13398 (re (concat "^" outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13399 level l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13400 (when (condition-case nil (org-back-to-heading t) (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13401 (setq level (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13402 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13403 (or previous (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13404 (while (funcall fun re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13405 (setq l (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13406 (when (< l level) (goto-char pos) (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13407 (when (= l level) (goto-char (match-beginning 0)) (throw 'exit t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13408 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13409 nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13410
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13411 (defun org-show-siblings ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13412 "Show all siblings of the current headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13413 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13414 (while (org-goto-sibling) (org-flag-heading nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13415 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13416 (while (org-goto-sibling 'previous)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13417 (org-flag-heading nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13418
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13419 (defun org-show-hidden-entry ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13420 "Show an entry where even the heading is hidden."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13421 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13422 (org-show-entry)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13423
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13424 (defun org-flag-heading (flag &optional entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13425 "Flag the current heading. FLAG non-nil means make invisible.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13426 When ENTRY is non-nil, show the entire entry."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13427 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13428 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13429 ;; Check if we should show the entire entry
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13430 (if entry
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13431 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13432 (org-show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13433 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13434 (and (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13435 (org-flag-heading nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13436 (outline-flag-region (max (point-min) (1- (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13437 (save-excursion (outline-end-of-heading) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13438 flag))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13439
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13440 (defun org-end-of-subtree (&optional invisible-OK to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13441 ;; This is an exact copy of the original function, but it uses
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13442 ;; `org-back-to-heading', to make it work also in invisible
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13443 ;; trees. And is uses an invisible-OK argument.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13444 ;; Under Emacs this is not needed, but the old outline.el needs this fix.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13445 (org-back-to-heading invisible-OK)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13446 (let ((first t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13447 (level (funcall outline-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13448 (while (and (not (eobp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13449 (or first (> (funcall outline-level) level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13450 (setq first nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13451 (outline-next-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13452 (unless to-heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13453 (if (memq (preceding-char) '(?\n ?\^M))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13454 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13455 ;; Go to end of line before heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13456 (forward-char -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13457 (if (memq (preceding-char) '(?\n ?\^M))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13458 ;; leave blank line before heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13459 (forward-char -1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13460 (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13461
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13462 (defun org-show-subtree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13463 "Show everything after this heading at deeper levels."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13464 (outline-flag-region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13465 (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13466 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13467 (outline-end-of-subtree) (outline-next-heading) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13468 nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13469
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13470 (defun org-show-entry ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13471 "Show the body directly following this heading.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13472 Show the heading too, if it is currently invisible."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13473 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13474 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13475 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13476 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13477 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13478 (outline-flag-region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13479 (max (point-min) (1- (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13480 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13481 (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13482 (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13483 (or (match-beginning 1) (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13484 nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13485 (error nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13486
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13487 (defun org-make-options-regexp (kwds)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13488 "Make a regular expression for keyword lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13489 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13490 "^"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13491 "#?[ \t]*\\+\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13492 (mapconcat 'regexp-quote kwds "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13493 "\\):[ \t]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13494 "\\(.+\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13495
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13496 ;; Make isearch reveal the necessary context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13497 (defun org-isearch-end ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13498 "Reveal context after isearch exits."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13499 (when isearch-success ; only if search was successful
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13500 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13501 ;; Under XEmacs, the hook is run in the correct place,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13502 ;; we directly show the context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13503 (org-show-context 'isearch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13504 ;; In Emacs the hook runs *before* restoring the overlays.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13505 ;; So we have to use a one-time post-command-hook to do this.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13506 ;; (Emacs 22 has a special variable, see function `org-mode')
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13507 (unless (and (boundp 'isearch-mode-end-hook-quit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13508 isearch-mode-end-hook-quit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13509 ;; Only when the isearch was not quitted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13510 (org-add-hook 'post-command-hook 'org-isearch-post-command
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13511 'append 'local)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13512
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13513 (defun org-isearch-post-command ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13514 "Remove self from hook, and show context."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13515 (remove-hook 'post-command-hook 'org-isearch-post-command 'local)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13516 (org-show-context 'isearch))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13517
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13518
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13519 ;;;; Integration with and fixes for other packages
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13520
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13521 ;;; Imenu support
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13522
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13523 (defvar org-imenu-markers nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13524 "All markers currently used by Imenu.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13525 (make-variable-buffer-local 'org-imenu-markers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13526
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13527 (defun org-imenu-new-marker (&optional pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13528 "Return a new marker for use by Imenu, and remember the marker."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13529 (let ((m (make-marker)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13530 (move-marker m (or pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13531 (push m org-imenu-markers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13532 m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13533
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13534 (defun org-imenu-get-tree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13535 "Produce the index for Imenu."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13536 (mapc (lambda (x) (move-marker x nil)) org-imenu-markers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13537 (setq org-imenu-markers nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13538 (let* ((n org-imenu-depth)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13539 (re (concat "^" outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13540 (subs (make-vector (1+ n) nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13541 (last-level 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13542 m tree level head)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13543 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13544 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13545 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13546 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13547 (while (re-search-backward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13548 (setq level (org-reduced-level (funcall outline-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13549 (when (<= level n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13550 (looking-at org-complex-heading-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13551 (setq head (org-match-string-no-properties 4)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13552 m (org-imenu-new-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13553 (org-add-props head nil 'org-imenu-marker m 'org-imenu t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13554 (if (>= level last-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13555 (push (cons head m) (aref subs level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13556 (push (cons head (aref subs (1+ level))) (aref subs level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13557 (loop for i from (1+ level) to n do (aset subs i nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13558 (setq last-level level)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13559 (aref subs 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13560
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13561 (eval-after-load "imenu"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13562 '(progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13563 (add-hook 'imenu-after-jump-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13564 (lambda () (org-show-context 'org-goto)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13565
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13566 ;; Speedbar support
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13567
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13568 (defvar org-speedbar-restriction-lock-overlay (org-make-overlay 1 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13569 "Overlay marking the agenda restriction line in speedbar.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13570 (org-overlay-put org-speedbar-restriction-lock-overlay
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13571 'face 'org-agenda-restriction-lock)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13572 (org-overlay-put org-speedbar-restriction-lock-overlay
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13573 'help-echo "Agendas are currently limited to this item.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13574 (org-detach-overlay org-speedbar-restriction-lock-overlay)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13575
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13576 (defun org-speedbar-set-agenda-restriction ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13577 "Restrict future agenda commands to the location at point in speedbar.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13578 To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13579 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13580 (require 'org-agenda)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13581 (let (p m tp np dir txt w)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13582 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13583 ((setq p (text-property-any (point-at-bol) (point-at-eol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13584 'org-imenu t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13585 (setq m (get-text-property p 'org-imenu-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13586 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13587 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13588 (set-buffer (marker-buffer m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13589 (goto-char m)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13590 (org-agenda-set-restriction-lock 'subtree))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13591 ((setq p (text-property-any (point-at-bol) (point-at-eol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13592 'speedbar-function 'speedbar-find-file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13593 (setq tp (previous-single-property-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13594 (1+ p) 'speedbar-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13595 np (next-single-property-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13596 tp 'speedbar-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13597 dir (speedbar-line-directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13598 txt (buffer-substring-no-properties (or tp (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13599 (or np (point-max))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13600 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13601 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13602 (set-buffer (find-file-noselect
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13603 (let ((default-directory dir))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13604 (expand-file-name txt))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13605 (unless (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13606 (error "Cannot restrict to non-Org-mode file"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13607 (org-agenda-set-restriction-lock 'file))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13608 (t (error "Don't know how to restrict Org-mode's agenda")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13609 (org-move-overlay org-speedbar-restriction-lock-overlay
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13610 (point-at-bol) (point-at-eol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13611 (setq current-prefix-arg nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13612 (org-agenda-maybe-redo)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13613
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13614 (eval-after-load "speedbar"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13615 '(progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13616 (speedbar-add-supported-extension ".org")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13617 (define-key speedbar-file-key-map "<" 'org-speedbar-set-agenda-restriction)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13618 (define-key speedbar-file-key-map "\C-c\C-x<" 'org-speedbar-set-agenda-restriction)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13619 (define-key speedbar-file-key-map ">" 'org-agenda-remove-restriction-lock)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13620 (define-key speedbar-file-key-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13621 (add-hook 'speedbar-visiting-tag-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13622 (lambda () (org-show-context 'org-goto)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13623
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13624
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13625 ;;; Fixes and Hacks for problems with other packages
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13626
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13627 ;; Make flyspell not check words in links, to not mess up our keymap
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13628 (defun org-mode-flyspell-verify ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13629 "Don't let flyspell put overlays at active buttons."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13630 (not (get-text-property (point) 'keymap)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13631
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13632 ;; Make `bookmark-jump' show the jump location if it was hidden.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13633 (eval-after-load "bookmark"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13634 '(if (boundp 'bookmark-after-jump-hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13635 ;; We can use the hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13636 (add-hook 'bookmark-after-jump-hook 'org-bookmark-jump-unhide)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13637 ;; Hook not available, use advice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13638 (defadvice bookmark-jump (after org-make-visible activate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13639 "Make the position visible."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13640 (org-bookmark-jump-unhide))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13641
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13642 (defun org-bookmark-jump-unhide ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13643 "Unhide the current position, to show the bookmark location."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13644 (and (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13645 (or (org-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13646 (save-excursion (goto-char (max (point-min) (1- (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13647 (org-invisible-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13648 (org-show-context 'bookmark-jump)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13649
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13650 ;; Make session.el ignore our circular variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13651 (eval-after-load "session"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13652 '(add-to-list 'session-globals-exclude 'org-mark-ring))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13653
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13654 ;;;; Experimental code
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13655
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13656 (defun org-closed-in-range ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13657 "Sparse tree of items closed in a certain time range.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13658 Still experimental, may disappear in the future."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13659 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13660 ;; Get the time interval from the user.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13661 (let* ((time1 (time-to-seconds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13662 (org-read-date nil 'to-time nil "Starting date: ")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13663 (time2 (time-to-seconds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13664 (org-read-date nil 'to-time nil "End date:")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13665 ;; callback function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13666 (callback (lambda ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13667 (let ((time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13668 (time-to-seconds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13669 (apply 'encode-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13670 (org-parse-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13671 (match-string 1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13672 ;; check if time in interval
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13673 (and (>= time time1) (<= time time2))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13674 ;; make tree, check each match with the callback
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13675 (org-occur "CLOSED: +\\[\\(.*?\\)\\]" nil callback)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13676
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13677
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13678 ;;;; Finish up
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13679
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13680 (provide 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13681
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13682 (run-hooks 'org-load-hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13683
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13684 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13685 ;;; org.el ends here
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13686
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13687