annotate lisp/org/org.el @ 99717:f6ad8a3462f6

(org-agenda-change-all-lines): Fix declaration.
author Glenn Morris <rgm@gnu.org>
date Wed, 19 Nov 2008 04:35:16 +0000
parents 1c73544f73bf
children 621e15919df0
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
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8 ;; Version: 6.12a
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)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
89 (require 'org-list)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
90
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
91 ;;;; Customization variables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93 ;;; Version
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
95 (defconst org-version "6.12a"
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96 "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
97
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 (defun org-version (&optional here)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99 "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
100 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
101 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102 (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
103 (message version)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 (if here
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105 (insert version))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107 ;;; Compatibility constants
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109 ;;; The custom variables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 (defgroup org nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 "Outline-based notes management and organizer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 :tag "Org"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 :group 'outlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115 :group 'hypermedia
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 :group 'calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 (defcustom org-load-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 "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
120 :group 'org
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
123 (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
124 (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
125 "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
126
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
127 (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
128 "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
129 (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
130 (mapc (lambda (ext)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
131 (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
132 (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
133 org-modules)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
134 (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
135
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
136 (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
137 "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
138 (set var value)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
139 (when (featurep 'org)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
140 (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
141
94876
ee90761f44b6 * org/org.el (org-modules): Repair problems with loading
Carsten Dominik <dominik@science.uva.nl>
parents: 94764
diff changeset
142 (when (org-bound-and-true-p org-modules)
ee90761f44b6 * org/org.el (org-modules): Repair problems with loading
Carsten Dominik <dominik@science.uva.nl>
parents: 94764
diff changeset
143 (let ((a (member 'org-infojs org-modules)))
ee90761f44b6 * org/org.el (org-modules): Repair problems with loading
Carsten Dominik <dominik@science.uva.nl>
parents: 94764
diff changeset
144 (and a (setcar a 'org-jsinfo))))
ee90761f44b6 * org/org.el (org-modules): Repair problems with loading
Carsten Dominik <dominik@science.uva.nl>
parents: 94764
diff changeset
145
ee90761f44b6 * org/org.el (org-modules): Repair problems with loading
Carsten Dominik <dominik@science.uva.nl>
parents: 94764
diff changeset
146 (defcustom org-modules '(org-bbdb org-bibtex org-gnus org-info org-jsinfo org-irc org-mew org-mhe org-rmail org-vm org-wl)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
147 "Modules that should always be loaded together with org.el.
94764
b0f118394bb4 (org-modules, org-format-latex-options): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 94749
diff changeset
148 If a description starts with <C>, the file is not part of Emacs
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
149 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
150 the org-mode distribution.
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 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
153 core modules, not modules from the CONTRIB directory). Just add symbols
94764
b0f118394bb4 (org-modules, org-format-latex-options): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 94749
diff changeset
154 to the end of the list. If the package is called org-xyz.el, then you need
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
155 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
156
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
157 (provide 'org-xyz)"
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 :group 'org
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
159 :set 'org-set-modules
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
160 :type
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
161 '(set :greedy t
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
162 (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
163 (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
164 (const :tag " gnus: Links to GNUS folders/messages" org-gnus)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
165 (const :tag " id: Global id's for identifying entries" org-id)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
166 (const :tag " info: Links to Info nodes" org-info)
94876
ee90761f44b6 * org/org.el (org-modules): Repair problems with loading
Carsten Dominik <dominik@science.uva.nl>
parents: 94764
diff changeset
167 (const :tag " jsinfo: Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
168 (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
169 (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
170 (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
171 (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
172 (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
173 (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
174 (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
175 (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
176
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
177 (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
178 (const :tag "C annotation-helper: Call Remeber directly from Browser" org-annotation-helper)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
179 (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
180 (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
181 (const :tag "C elisp-symbol: Org links to emacs-lisp symbols" org-elisp-symbol)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
182 (const :tag "C eval: Include command output as text" org-eval)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
183 (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
184 (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
185 (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
186 (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
187 (const :tag "C man: Support for links to manpages in Org-mode" org-man)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
188 (const :tag "C mtags: Support for muse-like tags" org-mtags)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
189 (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
190 (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
191 (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
192 (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
193 (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
194 (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
195 (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
196
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198 (defgroup org-startup nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 "Options concerning startup of Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 :tag "Org Startup"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 (defcustom org-startup-folded t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 "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
205 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
206 the following lines anywhere in the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208 #+STARTUP: fold
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 #+STARTUP: nofold
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210 #+STARTUP: content"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213 (const :tag "nofold: show all" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 (const :tag "fold: overview" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215 (const :tag "content: all headlines" content)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 (defcustom org-startup-truncated t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 "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
219 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
220 uninteresting. Also tables look terrible when wrapped."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
222 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
223
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 (defcustom org-startup-align-all-tables nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225 "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
226 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
227 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
228 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
229 the following lines anywhere in the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
230 #+STARTUP: align
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
231 #+STARTUP: noalign"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235 (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
236 "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
237 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
238 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
239 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
240 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
241 has been set."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245 (defcustom org-replace-disputed-keys nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
246 "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
247 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
248 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
249 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
250 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
251 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
252 `org-disputed-keys'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 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
255 *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
256 become effective."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
260 (defcustom org-use-extra-keys nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
261 "Non-nil means use extra key sequence definitions for certain
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
262 commands. This happens automatically if you run XEmacs or if
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
263 window-system is nil. This variable lets you do the same
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
264 manually. You must set it before loading org.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
265
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
266 Example: on Carbon Emacs 22 running graphically, with an external
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
267 keyboard on a Powerbook, the default way of setting M-left might
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
268 not work for either Alt or ESC. Setting this variable will make
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
269 it work for ESC."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
270 :group 'org-startup
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
271 :type 'boolean)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
272
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273 (if (fboundp 'defvaralias)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 (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
275
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
276 (defcustom org-disputed-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277 '(([(shift up)] . [(meta p)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278 ([(shift down)] . [(meta n)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279 ([(shift left)] . [(meta -)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
280 ([(shift right)] . [(meta +)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 ([(control shift right)] . [(meta shift +)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282 ([(control shift left)] . [(meta shift -)]))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283 "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
284 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
285 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
286
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
287 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
288 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
289 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
290 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 :type 'alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293 (defun org-key (key)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 "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
295 Or return the original if not disputed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 (if org-replace-disputed-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 (let* ((nkey (key-description key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298 (x (org-find-if (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
299 (equal (key-description (car x)) nkey))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
300 org-disputed-keys)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
301 (if x (cdr x) key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302 key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
303
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
304 (defun org-find-if (predicate seq)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
305 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
306 (while seq
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307 (if (funcall predicate (car seq))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
308 (throw 'exit (car seq))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
309 (pop seq)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
310
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
311 (defun org-defkey (keymap key def)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
312 "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
313 (define-key keymap (org-key key) def))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
314
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315 (defcustom org-ellipsis nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
316 "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
317 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
318 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
319 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
320 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
321 effective."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
322 :group 'org-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
323 :type '(choice (const :tag "Default" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
324 (face :tag "Face" :value org-warning)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
325 (string :tag "String" :value "...#")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
326
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
327 (defvar org-display-table nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
328 "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
329
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
330 (defgroup org-keywords nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331 "Keywords in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332 :tag "Org Keywords"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
333 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
334
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
335 (defcustom org-deadline-string "DEADLINE:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
336 "String to mark deadline entries.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
337 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
338 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
339 a timestamp with \\[org-deadline].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
340 Changes become only effective after restarting Emacs."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
341 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
342 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
344 (defcustom org-scheduled-string "SCHEDULED:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
345 "String to mark scheduled TODO entries.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
346 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
347 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
348 a timestamp with \\[org-schedule].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
349 Changes become only effective after restarting Emacs."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
350 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
351 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
352
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
353 (defcustom org-closed-string "CLOSED:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
354 "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
355 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
356 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
357
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
358 (defcustom org-clock-string "CLOCK:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
359 "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
360 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
361 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
362
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
363 (defcustom org-comment-string "COMMENT"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
364 "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
365 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
366 \\[org-toggle-comment].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
367 Changes become only effective after restarting Emacs."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
368 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
369 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
370
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
371 (defcustom org-quote-string "QUOTE"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
372 "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
373 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
374 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
375 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
376 \\[org-toggle-fixed-width-section]."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 (defconst org-repeat-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 "<[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
382 "Regular expression for specifying repeated events.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383 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
384
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385 (defgroup org-structure nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 "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
387 :tag "Org Structure"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390 (defgroup org-reveal-location nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391 "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
392 :tag "Org Reveal Location"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
394
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
395 (defconst org-context-choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
396 '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
397 (const :tag "Always" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
398 (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
399 (repeat :greedy t :tag "Individual contexts"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 (cons
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401 (choice :tag "Context"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402 (const agenda)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403 (const org-goto)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
404 (const occur-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
405 (const tags-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
406 (const link-search)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407 (const mark-goto)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 (const bookmark-jump)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409 (const isearch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
410 (const default))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
411 (boolean))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
412 "Contexts for the reveal options.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
414 (defcustom org-show-hierarchy-above '((default . t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
415 "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
416 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
417 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
418 above the exposed location is shown.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
419 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
420 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
421 contexts. Valid contexts are
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
422 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
423 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
424 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
425 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
426 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
427 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
428 bookmark-jump when exposing a bookmark location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 isearch when exiting from an incremental search
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 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
431 :group 'org-reveal-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
432 :type org-context-choice)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
433
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
434 (defcustom org-show-following-heading '((default . nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
435 "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
436 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
437 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
438 match is shown.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
439 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
440 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
441 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
442 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
443 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
444 :group 'org-reveal-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
445 :type org-context-choice)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
446
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447 (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
448 "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
449 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
450 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
451 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
452 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
453
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
454 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
455 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
456 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
457 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
458 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
459 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
460 :group 'org-reveal-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
461 :type org-context-choice)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
462
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
463 (defcustom org-show-entry-below '((default . nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
464 "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
465 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
466 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
467 exposed is also shown.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
468
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
469 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
470 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
471 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
472 :group 'org-reveal-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
473 :type org-context-choice)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
474
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
475 (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
476 "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
477 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
478 \\[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
479 Valid values are:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
480 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
481 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
482 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
483 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
484 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
485 kill these buffers yourself."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
486 :group 'org-structure
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
487 :group 'org-agenda-windows
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
488 :type '(choice
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
489 (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
490 (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
491 (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
492 (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
493
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
494 (defgroup org-cycle nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
495 "Options concerning visibility cycling in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
496 :tag "Org Cycle"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
497 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
498
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
499 (defcustom org-drawers '("PROPERTIES" "CLOCK")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
500 "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
501 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
502 this:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503 :DRAWERNAME:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
504 .....
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
505 :END:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
506 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
507 the property API.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
508
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
509 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
510
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 #+DRAWERS: HIDDEN STATE PROPERTIES"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 :group 'org-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
513 :type '(repeat (string :tag "Drawer Name")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
514
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515 (defcustom org-cycle-global-at-bob nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 "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
517 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
518 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
519 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
520 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
521 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
522 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
523 of the buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 :group 'org-cycle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
527 (defcustom org-cycle-emulate-tab t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528 "Where should `org-cycle' emulate TAB.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 nil Never
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 white Only in completely white lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 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
532 t Everywhere except in headlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 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
534 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
535 visibility is cycled."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
536 :group 'org-cycle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537 :type '(choice (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 (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
539 (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
540 (const :tag "Everywhere except in headlines" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541 (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
542 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
543
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544 (defcustom org-cycle-separator-lines 2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545 "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
546 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
547 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
548 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
549 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
550 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
551 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
552 following headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 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
555 :group 'org-cycle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556 :type 'integer)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
557 (put 'org-cycle-separator-lines 'safe-local-variable 'integerp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 (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
560 org-cycle-hide-drawers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 org-cycle-show-empty-lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 org-optimize-window-after-visibility-change)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 "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
564 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
565 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
566 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
567 `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
568 the values `folded', `children', or `subtree'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 :group 'org-cycle
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 (defgroup org-edit-structure nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 "Options concerning structure editing in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 :tag "Org Edit Structure"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 (defcustom org-odd-levels-only nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578 "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
579 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
580 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
581 handled by the exporters.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582 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
583 for fontification also in regions already fontified.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 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
585 lines to the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587 #+STARTUP: odd
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 #+STARTUP: oddeven"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 (defcustom org-adapt-indentation t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 "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
595 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
596 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
597 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
598 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
599 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
600 :type 'boolean)
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-a/e nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 "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
604 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
605 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
606 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
607 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
608 it to the beginning of the line.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 `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
610 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
611 line, after any tags.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
612 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
613 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
614 to the special positions."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
617 (const :tag "off" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 (const :tag "after bullet first" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619 (const :tag "border first" reversed)))
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 (if (fboundp 'defvaralias)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
622 (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
623
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
624 (defcustom org-special-ctrl-k nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
625 "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
626 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
627 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
628
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
629 - 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
630 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
631 - 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
632 - 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
633 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
634 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
635
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
636 (defcustom org-yank-folded-subtrees t
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
637 "Non-nil means, when yanking subtrees, fold them.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
638 If the kill is a single subtree, or a sequence of subtrees, i.e. if
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
639 it starts with a heading and all other headings in it are either children
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
640 or siblings, then fold all the subtrees. However, do this only if no
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
641 text after the yank would be swallowed into a folded tree by this action."
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
642 :group 'org-edit-structure
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
643 :type 'boolean)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
644
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
645 (defcustom org-yank-adjusted-subtrees t
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
646 "Non-nil means, when yanking subtrees, adjust the level.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
647 With this setting, `org-paste-subtree' is used to insert the subtree, see
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
648 this function for details."
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
649 :group 'org-edit-structure
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
650 :type 'boolean)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
651
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
652 (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
653 "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
654 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
655 new line.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656 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
657 contexts. Valid contexts are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
658
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
659 headline when creating a new headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
660 item when creating a new item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
661 table in a table field
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 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
663 customized"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 :group 'org-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
665 :group 'org-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 (const :tag "Always" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
668 (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
669 (repeat :greedy t :tag "Individual contexts"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
670 (cons
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
671 (choice :tag "Context"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
672 (const headline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
673 (const item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
674 (const table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
675 (const default))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
676 (boolean)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
677
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
678
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
679 (defcustom org-insert-heading-respect-content nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
680 "Non-nil means, insert new headings after the current subtree.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
681 When nil, the new heading is created directly after the current line.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
682 The commands \\[org-insert-heading-respect-content] and
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
683 \\[org-insert-todo-heading-respect-content] turn this variable on
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
684 for the duration of the command."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
685 :group 'org-structure
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
686 :type 'boolean)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
687
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
688 (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
689 (plain-list-item . nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
690 "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
691 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
692 and a boolean flag as cdr."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
694 :type '(list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
695 (cons (const heading) (boolean))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696 (cons (const plain-list-item) (boolean))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
697
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
698 (defcustom org-insert-heading-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
699 "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
700 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
701 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
702
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
703 (defcustom org-enable-fixed-width-editor t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
704 "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
705 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
706 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
707 See also the QUOTE keyword."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
708 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
709 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
710
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
711 (defcustom org-edit-src-region-extra nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
712 "Additional regexps to identify regions for editing with `org-edit-src-code'.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
713 For examples see the function `org-edit-src-find-region-and-lang'.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
714 The regular expression identifying the begin marker should end with a newline,
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
715 and the regexp marking the end line should start with a newline, to make sure
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
716 there are kept outside the narrowed region."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
717 :group 'org-edit-structure
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
718 :type '(repeat
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
719 (list
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
720 (regexp :tag "begin regexp")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
721 (regexp :tag "end regexp")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
722 (choice :tag "language"
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
723 (string :tag "specify")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
724 (integer :tag "from match group")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
725 (const :tag "from `lang' element")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
726 (const :tag "from `style' element")))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
727
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
728 (defcustom org-edit-fixed-width-region-mode 'artist-mode
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
729 "The mode that should be used to edit fixed-width regions.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
730 These are the regions where each line starts with a colon."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
731 :group 'org-edit-structure
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
732 :type '(choice
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
733 (const artist-mode)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
734 (const picture-mode)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
735 (const fundamental-mode)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
736 (function :tag "Other (specify)")))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
737
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
738 (defcustom org-goto-auto-isearch t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739 "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
740 :group 'org-edit-structure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
741 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
743 (defgroup org-sparse-trees nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
744 "Options concerning sparse trees in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 :tag "Org Sparse Trees"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746 :group 'org-structure)
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 (defcustom org-highlight-sparse-tree-matches t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749 "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
750 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
751 changed by an edit command."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752 :group 'org-sparse-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
753 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
754
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755 (defcustom org-remove-highlights-with-change t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756 "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
757 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
758 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
759 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
760 `C-c C-c' to be removed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
761 :group 'org-sparse-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
762 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
764
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
765
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
766 (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
767 "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
768 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
769 as possible."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
770 :group 'org-sparse-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
772
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
773 (defgroup org-imenu-and-speedbar nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774 "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
775 :tag "Org Imenu and Speedbar"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776 :group 'org-structure)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
777
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
778 (defcustom org-imenu-depth 2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
779 "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
780 This also applied for speedbar access."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
781 :group 'org-imenu-and-speedbar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
782 :type 'number)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
783
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
784 (defgroup org-table nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
785 "Options concerning tables in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
786 :tag "Org Table"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
787 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
788
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
789 (defcustom org-enable-table-editor 'optimized
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
790 "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
791 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
792
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
793 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
794 do the following:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
795 - 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
796 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
797 field does not exceed the column width.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 - 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
799 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
800 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
801 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
802 `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
803 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
804 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
805 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
806
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
807 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
808 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
809
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
810 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
811 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
812
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
813 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
814 :group 'org-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
815 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
816 (const :tag "off" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
817 (const :tag "on" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
818 (const :tag "on, optimized" optimized)))
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 (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
821 "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
822 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
823 calls `table-recognize-table'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
824 :group 'org-table-editing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
825 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
826
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
827 (defgroup org-link nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
828 "Options concerning links in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
829 :tag "Org Link"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
830 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
831
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
832 (defvar org-link-abbrev-alist-local nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
833 "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
834 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
835 (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
836
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
837 (defcustom org-link-abbrev-alist nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
838 "Alist of link abbreviations.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
839 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
840 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
841 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
842
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
843 [[linkkey:tag][description]]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
844
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
845 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
846 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
847
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
848 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
849 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
850
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851 See the manual for examples."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
852 :group 'org-link
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
853 :type '(repeat
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
854 (cons
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
855 (string :tag "Protocol")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
856 (choice
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
857 (string :tag "Format")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
858 (function)))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
859
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
860 (defcustom org-descriptive-links t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
861 "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
862 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
863 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
864 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
865 :group 'org-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
866 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
867
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
868 (defcustom org-link-file-path-type 'adaptive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
869 "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
870 Valid values are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
871
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
872 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
873 into which the link is being inserted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
874 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
875 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
876 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
877 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
878 :group 'org-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
879 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
880 (const relative)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
881 (const absolute)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
882 (const noabbrev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
883 (const adaptive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
884
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
885 (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
886 "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
887 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
888 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
889 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
890
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
891 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
892 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
893 <bbdb:Carsten Dominik>.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
894 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
895 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
896 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
897 date Time stamps (link to calendar).
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
898
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
899 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
900 :group 'org-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
901 :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
902 (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
903 (const :tag "Plain text links" plain)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
904 (const :tag "Radio target matches" radio)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
905 (const :tag "Tags" tag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
906 (const :tag "Timestamps" date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
907
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
908 (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
909 "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
910 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
911 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
912 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
913 to use."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
914 :group 'org-link
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
915 :type 'function)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
916
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
917 (defgroup org-link-store nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
918 "Options concerning storing links in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
919 :tag "Org Store Link"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
920 :group 'org-link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
921
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
922 (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
923 "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
924 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
925
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926 %F full \"From\" field
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
927 %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
928 %T full \"To\" field
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
929 %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
930 %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
931 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
932 %s subject
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
933 %m message-id.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
934
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
935 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
936 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
937
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
938 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
939 :group 'org-link-store
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
940 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
941
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
942 (defcustom org-from-is-user-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
943 (let (r1 r2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
944 (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
945 (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
946 (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
947 (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
948 (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
949 "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
950 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
951 :group 'org-link-store
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
952 :type 'regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
953
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
954 (defcustom org-context-in-file-links t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
955 "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
956 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
957 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
958 `org-open-at-point'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
959 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
960 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
961 :group 'org-link-store
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
962 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
963
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
964 (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
965 "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
966
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
967 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
968 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
969 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
970 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
971 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
972 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
973 more efficient."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974 :group 'org-link-store
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 (defgroup org-link-follow nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
978 "Options concerning following links in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
979 :tag "Org Follow Link"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
980 :group 'org-link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
982 (defcustom org-follow-link-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
983 "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
984 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
985 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
986
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
987 (defcustom org-tab-follows-link nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
988 "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
989 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
990 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
991 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
992
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
993 (defcustom org-return-follows-link nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
994 "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
995 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
996 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
997 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
998
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
999 (defcustom org-mouse-1-follows-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1000 (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
1001 "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
1002 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
1003 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
1004 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1005 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1007 (defcustom org-mark-ring-length 4
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1008 "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
1009 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
1010 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1011 :type 'interger)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1012
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1013 (defcustom org-link-frame-setup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1014 '((vm . vm-visit-folder-other-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1015 (gnus . gnus-other-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1016 (file . find-file-other-window))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1017 "Setup the frame configuration for following links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1018 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
1019 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
1020 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
1021 For VM, use any of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1022 `vm-visit-folder'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1023 `vm-visit-folder-other-frame'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1024 For Gnus, use any of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1025 `gnus'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1026 `gnus-other-frame'
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1027 `org-gnus-no-new-news'
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1028 For FILE, use any of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1029 `find-file'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1030 `find-file-other-window'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1031 `find-file-other-frame'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1032 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
1033 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
1034 another window."
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 '(list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1037 (cons (const vm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1038 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1039 (const vm-visit-folder)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1040 (const vm-visit-folder-other-window)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1041 (const vm-visit-folder-other-frame)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1042 (cons (const gnus)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1043 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1044 (const gnus)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1045 (const gnus-other-frame)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1046 (const org-gnus-no-new-news)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1047 (cons (const file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1048 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1049 (const find-file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1050 (const find-file-other-window)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1051 (const find-file-other-frame)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1052
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1053 (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
1054 "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
1055 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
1056 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
1057 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
1058 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
1059 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
1060 changes to the current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1061 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1062 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1063
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1064 (defcustom org-open-non-existing-files nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1065 "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
1066 When nil, an error will be generated."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1067 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1068 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1069
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
1070 (defcustom org-open-directory-means-index-dot-org nil
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
1071 "Non-nil means, a link to a directory really means to index.org.
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
1072 When nil, following a directory link will run dired or open a finder/explorer
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
1073 window on that directory."
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
1074 :group 'org-link-follow
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
1075 :type 'boolean)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
1076
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1077 (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
1078 "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
1079 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
1080 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
1081 %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
1082 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
1083 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1084 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1085 (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
1086 (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
1087 (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
1088 (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
1089
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1090 (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
1091 "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
1092 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
1093
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1094 [[shell:rm -rf ~/*][Google Search]]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1095
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1096 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
1097 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
1098 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
1099 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
1100 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
1101 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1102 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1103 (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
1104 (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
1105 (const :tag "no confirmation (dangerous)" nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1106
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1107 (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
1108 "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
1109 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
1110
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1111 [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1112
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1113 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
1114 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
1115 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
1116 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
1117 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
1118 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1119 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1120 (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
1121 (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
1122 (const :tag "no confirmation (dangerous)" nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1123
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1124 (defconst org-file-apps-defaults-gnu
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1125 '((remote . emacs)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1126 (system . mailcap)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1127 (t . mailcap))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1128 "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
1129 See `org-file-apps'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1130
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1131 (defconst org-file-apps-defaults-macosx
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1132 '((remote . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1133 (t . "open %s")
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1134 (system . "open %s")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1135 ("ps.gz" . "gv %s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1136 ("eps.gz" . "gv %s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1137 ("dvi" . "xdvi %s")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1138 ("fig" . "xfig %s"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1139 "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
1140 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
1141 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
1142 See `org-file-apps'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1143
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1144 (defconst org-file-apps-defaults-windowsnt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1145 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1146 '(remote . emacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1147 (cons t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1148 (list (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1149 'mswindows-shell-execute
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1150 'w32-shell-execute)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1151 "open" 'file))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1152 (cons 'system
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1153 (list (if (featurep 'xemacs)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1154 'mswindows-shell-execute
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1155 'w32-shell-execute)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1156 "open" 'file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1157 "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
1158 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
1159 See `org-file-apps'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1160
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1161 (defcustom org-file-apps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1162 '(
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1163 (auto-mode . emacs)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1164 ("\\.x?html?\\'" . default)
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1165 ("\\.pdf\\'" . default)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1166 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1167 "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
1168 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
1169 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
1170 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
1171 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
1172 file identifier are
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1173 \"regex\" Regular expression matched against the file name. For backward
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1174 compatibility, this can also be a string with only alphanumeric
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1175 characters, which is then interpreted as an extension.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1176 `directory' Matches a directory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1177 `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
1178 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
1179 because external applications cannot handle such paths.
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1180 `auto-mode' Matches files that are mached by any entry in `auto-mode-alist',
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1181 so all files Emacs knows how to handle. Using this with
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1182 command `emacs' will open most files in Emacs. Beware that this
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1183 will also open html files insite Emacs, unless you add
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1184 (\"html\" . default) to the list as well.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1185 t Default for files not matched by any of the other options.
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1186 `system' The system command to open files, like `open' on Windows
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1187 and Mac OS X, and mailcap under GNU/Linux. This is the command
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1188 that will be selected if you call `C-c C-o' with a double
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1189 `C-u C-u' prefix.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1190
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1191 Possible values for the command are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1192 `emacs' The file will be visited by the current Emacs process.
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1193 `default' Use the default application for this file type, which is the
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1194 association for t in the list, most likely in the system-specific
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1195 part.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1196 This can be used to overrule an unwanted seting in the
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1197 system-specific variable.
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1198 `system' Use the system command for opening files, like \"open\".
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1199 This command is specified by the entry whose car is `system'.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1200 Most likely, the system-specific version of this variable
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1201 does define this command, but you can overrule/replace it
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1202 here.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1203 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
1204 by the path to the file.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1205 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
1206 be available in the Lisp variable `file'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1207 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
1208 `org-file-apps-defaults-macosx'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1209 `org-file-apps-defaults-windowsnt'
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1210 `org-file-apps-defaults-gnu'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1211 :group 'org-link-follow
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1212 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1213 (cons (choice :value ""
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1214 (string :tag "Extension")
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1215 (const :tag "System command to open files" system)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1216 (const :tag "Default for unrecognized files" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1217 (const :tag "Remote file" remote)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1218 (const :tag "Links to a directory" directory)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1219 (const :tag "Any files that have Emacs modes"
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1220 auto-mode))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1221 (choice :value ""
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1222 (const :tag "Visit with Emacs" emacs)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1223 (const :tag "Use default" default)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1224 (const :tag "Use the system command" system)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1225 (string :tag "Command")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1226 (sexp :tag "Lisp form")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1227
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1228 (defgroup org-refile nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1229 "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
1230 :tag "Org Remember"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1231 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1232
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1233 (defcustom org-directory "~/org"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1234 "Directory with org files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1235 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
1236 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
1237 :group 'org-refile
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1238 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1239 :type 'directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1240
98870
48e8ecb5eb0e (org-default-notes-file): Run file names that begin with a period thru
Eli Zaretskii <eliz@gnu.org>
parents: 98644
diff changeset
1241 (defcustom org-default-notes-file (convert-standard-filename "~/.notes")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1242 "Default target for storing notes.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1243 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
1244 the value of `remember-data-file'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1245 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
1246 `org-remember-templates'."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1247 :group 'org-refile
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1248 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1249 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1250 (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
1251 file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1252
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1253 (defcustom org-goto-interface 'outline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1254 "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
1255 Allowed vaues are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1256 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
1257 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
1258 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
1259 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
1260 completion."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1261 :group 'org-refile
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1262 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1263 (const :tag "Outline" outline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1264 (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
1265
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1266 (defcustom org-reverse-note-order nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1267 "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
1268 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
1269 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
1270 are matched against file names, and values."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1271 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1272 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1273 (const :tag "Reverse always" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1274 (const :tag "Reverse never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1275 (repeat :tag "By file name regexp"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1276 (cons regexp boolean))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1277
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1278 (defcustom org-refile-targets nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1279 "Targets for refiling entries with \\[org-refile].
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1280 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
1281 - 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
1282 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
1283 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
1284 heading in the current buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1285 - 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
1286 any of
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1287 - 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
1288 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
1289 not be considered.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1290 - 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
1291 todo keyword.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1292 - 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
1293 headlines that are refiling targets.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1294 - a cons cell (:level . N). Any headline of level N is considered a target.
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1295 - a cons cell (:maxlevel . N). Any headline with level <= N is a target.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1296
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1297 When this variable is nil, all top-level headlines in the current buffer
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1298 are used, equivalent to the value `((nil . (:level . 1))'."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1299 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1300 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1301 (cons
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1302 (choice :value org-agenda-files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1303 (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
1304 (const :tag "Current buffer" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1305 (function) (variable) (file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1306 (choice :tag "Identify target headline by"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1307 (cons :tag "Specific tag" (const :tag) (string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1308 (cons :tag "TODO keyword" (const :todo) (string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1309 (cons :tag "Regular expression" (const :regexp) (regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1310 (cons :tag "Level number" (const :level) (integer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1311 (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
1312
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1313 (defcustom org-refile-use-outline-path nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1314 "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
1315 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
1316 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
1317 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
1318 :group 'org-remember
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1319 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1320 (const :tag "Not" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1321 (const :tag "Yes" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1322 (const :tag "Start with file name" file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1323 (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
1324
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1325 (defgroup org-todo nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1326 "Options concerning TODO items in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1327 :tag "Org TODO"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1328 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1329
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1330 (defgroup org-progress nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1331 "Options concerning Progress logging in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1332 :tag "Org Progress"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1333 :group 'org-time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1334
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1335 (defcustom org-todo-keywords '((sequence "TODO" "DONE"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1336 "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
1337 \\<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
1338
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1339 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
1340 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
1341 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
1342 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
1343 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
1344 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
1345 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
1346 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
1347
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1348 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
1349 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
1350 cycling, see the manual.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1351
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1352 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
1353 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
1354
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1355 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
1356 \(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
1357 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
1358 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
1359 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
1360 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
1361
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1362 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
1363 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
1364 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
1365 \"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
1366 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
1367 \"@\" 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
1368 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
1369 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
1370 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
1371
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1372 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
1373 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
1374 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
1375 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1376 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1377 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1378 (repeat :tag "Old syntax, just keywords"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1379 (string :tag "Keyword"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1380 (repeat :tag "New syntax"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1381 (cons
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1382 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1383 :tag "Interpretation"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1384 (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
1385 (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
1386 (repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1387 (string :tag "Keyword"))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1388
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1389 (defvar org-todo-keywords-1 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1390 "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
1391 (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
1392 (defvar org-todo-keywords-for-agenda nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1393 (defvar org-done-keywords-for-agenda nil)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1394 (defvar org-todo-keyword-alist-for-agenda nil)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1395 (defvar org-tag-alist-for-agenda nil)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1396 (defvar org-agenda-contributing-files nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1397 (defvar org-not-done-keywords nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1398 (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
1399 (defvar org-done-keywords nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1400 (make-variable-buffer-local 'org-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1401 (defvar org-todo-heads nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1402 (make-variable-buffer-local 'org-todo-heads)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1403 (defvar org-todo-sets nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1404 (make-variable-buffer-local 'org-todo-sets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1405 (defvar org-todo-log-states nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1406 (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
1407 (defvar org-todo-kwd-alist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1408 (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
1409 (defvar org-todo-key-alist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1410 (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
1411 (defvar org-todo-key-trigger nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1412 (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
1413
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1414 (defcustom org-todo-interpretation 'sequence
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1415 "Controls how TODO keywords are interpreted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1416 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
1417 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
1418 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
1419 more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1420 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1421 :group 'org-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1422 :type '(choice (const sequence)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1423 (const type)))
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-use-fast-todo-selection 'prefix
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1426 "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
1427 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
1428 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
1429 selection scheme.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1430
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1431 When nil, fast selection is never used.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1432
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1433 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
1434 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
1435 in an agenda buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1436
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1437 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
1438 argument forces cycling instead.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1439
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1440 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
1441 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
1442 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
1443 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1444 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1445 (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1446 (const :tag "By default" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1447 (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
1448
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1449 (defcustom org-provide-todo-statistics t
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1450 "Non-nil means, update todo statistics after insert and toggle.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1451 When this is set, todo statistics is updated in the parent of the current
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1452 entry each time a todo state is changed."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1453 :group 'org-todo
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1454 :type 'boolean)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1455
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1456 (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
1457 "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
1458 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
1459 Lisp variable `state'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1460 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1461 :type 'hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1462
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1463 (defcustom org-todo-state-tags-triggers nil
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1464 "Tag changes that should be triggered by TODO state changes.
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1465 This is a list. Each entry is
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1466
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1467 (state-change (tag . flag) .......)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1468
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1469 State-change can be a string with a state, and empty string to indicate the
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1470 state that has no TODO keyword, or it can be one of the symbols `todo'
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1471 or `done', meaning any not-done or done state, respectively."
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1472 :group 'org-todo
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1473 :group 'org-tags
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1474 :type '(repeat
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1475 (cons (choice :tag "When changing to"
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1476 (const :tag "Not-done state" todo)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1477 (const :tag "Done state" done)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1478 (string :tag "State"))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1479 (repeat
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1480 (cons :tag "Tag action"
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1481 (string :tag "Tag")
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1482 (choice (const :tag "Add" t) (const :tag "Remove" nil)))))))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1483
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1484 (defcustom org-log-done nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1485 "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
1486 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
1487 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
1488 the following lines anywhere in the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1489
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1490 #+STARTUP: logdone
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1491 #+STARTUP: lognotedone
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1492 #+STARTUP: nologdone"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1493 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1494 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1495 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1496 (const :tag "No logging" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1497 (const :tag "Record CLOSED timestamp" time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1498 (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
1499
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1500 ;; Normalize old uses of org-log-done.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1501 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1502 ((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
1503 ((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
1504 (setq org-log-done 'note)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1505
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1506 (defcustom org-log-note-clock-out nil
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1507 "Non-nil means, record a note when clocking out of an item.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1508 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
1509 the following lines anywhere in the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1510
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1511 #+STARTUP: lognoteclock-out
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1512 #+STARTUP: nolognoteclock-out"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1513 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1514 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1515 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1516
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1517 (defcustom org-log-done-with-time t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1518 "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
1519 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
1520 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1521 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1522
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1523 (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
1524 '((done . "CLOSING NOTE %t")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1525 (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
1526 (note . "Note taken on %t")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1527 (clock-out . ""))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1528 "Headings for notes added to entries.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1529 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
1530 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
1531 empty string.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1532 %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
1533 %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
1534 %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
1535 %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
1536 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1537 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1538 :type '(list :greedy t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1539 (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
1540 (cons (const :tag
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1541 "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
1542 state) string)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1543 (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
1544 (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
1545
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1546 (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
1547 (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
1548
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1549 (defcustom org-log-state-notes-insert-after-drawers nil
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1550 "Non-nil means, insert state change notes after any drawers in entry.
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1551 Only the drawers that *immediately* follow the headline and the
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1552 deadline/scheduled line are skipped.
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1553 When nil, insert notes right after the heading and perhaps the line
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1554 with deadline/scheduling if present."
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1555 :group 'org-todo
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1556 :group 'org-progress
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1557 :type 'boolean)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1558
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1559 (defcustom org-log-states-order-reversed t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1560 "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
1561 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
1562 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1563 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1564 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1565
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1566 (defcustom org-log-repeat 'time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1567 "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
1568 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
1569 done. If you are not logging state changes (by adding \"@\" or \"!\" to
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1570 the TODO keyword definition, or recording a closing note by setting
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1571 `org-log-done', there will be no record of the task moving through DONE.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1572 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
1573
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1574 nil Don't force a record
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1575 time Record a time stamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1576 note Record a note
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1577
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1578 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
1579
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1580 #+STARTUP: logrepeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1581 #+STARTUP: lognoterepeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1582 #+STARTUP: nologrepeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1583
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1584 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
1585 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
1586 :group 'org-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1587 :group 'org-progress
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1588 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1589 (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
1590 (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
1591 (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
1592
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1593
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1594 (defgroup org-priorities nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1595 "Priorities in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1596 :tag "Org Priorities"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1597 :group 'org-todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1598
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1599 (defcustom org-highest-priority ?A
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1600 "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
1601 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
1602 :group 'org-priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1603 :type 'character)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1604
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1605 (defcustom org-lowest-priority ?C
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1606 "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
1607 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
1608 :group 'org-priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1609 :type 'character)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1610
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1611 (defcustom org-default-priority ?B
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1612 "The default priority of TODO items.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1613 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
1614 :group 'org-priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1615 :type 'character)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1616
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1617 (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
1618 "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
1619 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
1620 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
1621 :group 'org-priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1622 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1623
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1624 (defgroup org-time nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1625 "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
1626 :tag "Org Time"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1627 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1628
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1629 (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
1630 "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
1631 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
1632 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
1633 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
1634 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1635 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1636
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1637 (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
1638 "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
1639 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
1640
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1641 (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
1642 "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
1643 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
1644 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
1645 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
1646 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
1647
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1648 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
1649 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
1650
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1651 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
1652 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
1653 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
1654 of minutes to shift."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1655 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1656 :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
1657 (if (integerp (default-value var))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1658 (list (default-value var) 5)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1659 (default-value var)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1660 :type '(list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1661 (integer :tag "when inserting times")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1662 (integer :tag "when modifying times")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1663
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1664 ;; Normalize old customizations of this variable.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1665 (when (integerp org-time-stamp-rounding-minutes)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1666 (setq org-time-stamp-rounding-minutes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1667 (list org-time-stamp-rounding-minutes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1668 org-time-stamp-rounding-minutes)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1669
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1670 (defcustom org-display-custom-times nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1671 "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
1672 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
1673 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
1674 #+STARTUP: customtime"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1675 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1676 :set 'set-default
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1677 :type 'sexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1678 (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
1679
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1680 (defcustom org-time-stamp-custom-formats
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1681 '("<%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
1682 "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
1683 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
1684 `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
1685 end of the second format."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1686 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1687 :type 'sexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1688
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1689 (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
1690 "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
1691 (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
1692 (car org-time-stamp-formats))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1693 (if inactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1694 (concat "[" (substring f 1 -1) "]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1695 f)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1696
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1697 (defcustom org-time-clocksum-format "%d:%02d"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1698 "The format string used when creating CLOCKSUM lines, or when
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1699 org-mode generates a time duration."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1700 :group 'org-time
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1701 :type 'string)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
1702
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1703 (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
1704 "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
1705 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
1706 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
1707 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
1708 :group 'org-time
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1709 :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
1710 :type 'number)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1711
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1712 (defcustom org-read-date-prefer-future t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1713 "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
1714 This affects the following situations:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1715 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
1716 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
1717 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
1718 it will be considered as *this* month.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1719 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
1720 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
1721 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
1722
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1723 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
1724
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1725 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
1726 as defaults."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1727 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1728 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1729
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1730 (defcustom org-read-date-display-live t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1731 "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
1732 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
1733 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1734 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1735
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1736 (defcustom org-read-date-popup-calendar t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1737 "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
1738 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
1739 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
1740 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
1741 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1742 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1743 (if (fboundp 'defvaralias)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1744 (defvaralias 'org-popup-calendar-for-date-prompt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1745 'org-read-date-popup-calendar))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1746
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1747 (defcustom org-extend-today-until 0
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1748 "The hour when your day really ends. Must be an integer.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1749 This has influence for the following applications:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1750 - 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
1751 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
1752 - 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
1753 here, the current date and time will be assumed to be yesterday, 23:59.
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1754 Also, timestamps inserted in remember templates follow this rule.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1755
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1756 IMPORTANT: This is a feature whose implementation is and likely will
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1757 remain incomplete. Really, it is only here because past midnight seems to
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
1758 be the favorite working time of John Wiegley :-)"
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1759 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1760 :type 'number)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1761
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1762 (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
1763 "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
1764 When nil, S-up will increase."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1765 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1766 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1767
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1768 (defcustom org-calendar-follow-timestamp-change t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1769 "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
1770 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
1771 moved to the new date."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1772 :group 'org-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1773 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1774
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1775 (defgroup org-tags nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1776 "Options concerning tags in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1777 :tag "Org Tags"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1778 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1779
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1780 (defcustom org-tag-alist nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1781 "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
1782 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
1783 buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1784 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
1785 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
1786 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
1787 See the manual for details."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1788 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1789 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1790 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1791 (cons (string :tag "Tag name")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1792 (character :tag "Access char"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1793 (const :tag "Start radio group" (:startgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1794 (const :tag "End radio group" (:endgroup)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1795
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1796 (defvar org-file-tags nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1797 "List of tags that can be inherited by all entries in the file.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1798 The tags will be inherited if the variable `org-use-tag-inheritance'
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1799 says they should be.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1800 This variable is populated from #+TAG lines.")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1801
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1802 (defcustom org-use-fast-tag-selection 'auto
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1803 "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
1804 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
1805 When nil, fast selection is never used.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1806 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
1807 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
1808 `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
1809 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
1810 automatically if necessary."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1811 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1812 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1813 (const :tag "Always" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1814 (const :tag "Never" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1815 (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
1816
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1817 (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
1818 "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
1819 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
1820 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
1821 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
1822 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
1823 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1824 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1825 (const :tag "No" nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1826 (const :tag "Yes" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1827 (const :tag "Expert" expert)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1828
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1829 (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
1830 "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
1831 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
1832
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1833 (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
1834 "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
1835 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
1836 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
1837 -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
1838 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1839 :type 'integer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1840
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1841 (defcustom org-auto-align-tags t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1842 "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
1843 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
1844 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
1845 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
1846 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1847 :type 'boolean)
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 (defcustom org-use-tag-inheritance t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1850 "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
1851 When nil, only the tags directly given in a specific line apply there.
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1852 If this option is t, a match early-on in a tree can lead to a large
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1853 number of matches in the subtree. If you only want to see the first
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1854 match in a tree during a search, check out the variable
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1855 `org-tags-match-list-sublevels'.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1856
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1857 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
1858 matches tags that should be inherited."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1859 :group 'org-tags
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1860 :type '(choice
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1861 (const :tag "Not" nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1862 (const :tag "Always" t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1863 (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
1864 (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
1865
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1866 (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
1867 "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
1868 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1869 ((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
1870 ((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
1871 ((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
1872 (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
1873 ((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
1874 (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
1875 (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
1876
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1877 (defcustom org-tags-match-list-sublevels t
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1878 "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
1879 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
1880 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
1881 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
1882 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
1883 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
1884 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
1885
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1886 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
1887 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
1888 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
1889 :group 'org-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1890 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1891
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1892 (defvar org-tags-history nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1893 "History of minibuffer reads for tags.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1894 (defvar org-last-tags-completion-table nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1895 "The last used completion table for tags.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1896 (defvar org-after-tags-change-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1897 "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
1898
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1899 (defgroup org-properties nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1900 "Options concerning properties in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1901 :tag "Org Properties"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1902 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1903
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1904 (defcustom org-property-format "%-10s %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1905 "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
1906 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
1907 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
1908 lined-up with respect to each other."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1909 :group 'org-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1910 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1911
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1912 (defcustom org-use-property-inheritance nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1913 "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
1914
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1915 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
1916 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
1917 on by default.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1918
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1919 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
1920 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
1921 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
1922 properties that should be inherited.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1923
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1924 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
1925 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
1926 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
1927 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
1928
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1929 Note for programmers:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1930 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
1931 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
1932 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
1933 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
1934 in this variable)."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1935 :group 'org-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1936 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1937 (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
1938 (const :tag "Always" t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1939 (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
1940 (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
1941
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1942 (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
1943 "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
1944 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1945 ((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
1946 ((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
1947 ((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
1948 (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
1949 ((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
1950 (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
1951 (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
1952
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1953 (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
1954 "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
1955 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
1956
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1957 #+COLUMNS: %25ITEM ....."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1958 :group 'org-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1959 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1960
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1961 (defcustom org-columns-ellipses ".."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1962 "The ellipses to be used when a field in column view is truncated.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1963 When this is the empty string, as many characters as possible are shown,
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1964 but then there will be no visual indication that the field has been truncated.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1965 When this is a string of length N, the last N characters of a truncated
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1966 field are replaced by this string. If the column is narrower than the
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1967 ellipses string, only part of the ellipses string will be shown."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1968 :group 'org-properties
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1969 :type 'string)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1970
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1971 (defcustom org-columns-modify-value-for-display-function nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1972 "Function that modifies values for display in column view.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1973 For example, it can be used to cut out a certain part from a time stamp.
99386
e9a50f67e0c7 * org.el (org-columns-modify-value-for-display-function):
Juanma Barranquero <lekktu@gmail.com>
parents: 99139
diff changeset
1974 The function must take 2 arguments:
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1975
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1976 column-title The tite of the column (*not* the property name)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1977 value The value that should be modified.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1978
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1979 The function should return the value that should be displayed,
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1980 or nil if the normal value should be used."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1981 :group 'org-properties
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
1982 :type 'function)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1983
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1984 (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
1985 "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
1986 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
1987 :group 'org-properties
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1988 :group 'org-progress
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1989 :type '(string :tag "Property"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
1990
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1991 (defconst org-global-properties-fixed
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1992 '(("VISIBILITY_ALL" . "folded children content all"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1993 "List of property/value pairs that can be inherited by any entry.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1994 These are fixed values, for the preset properties.")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1995
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
1996
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1997 (defcustom org-global-properties nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1998 "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
1999 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
2000
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2001 #+PROPERTY: NAME VALUE"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2002 :group 'org-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2003 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2004 (cons (string :tag "Property")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2005 (string :tag "Value"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2006
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2007 (defvar org-file-properties nil
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2008 "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
2009 Valid for the current buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2010 This variable is populated from #+PROPERTY lines.")
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2011 (make-variable-buffer-local 'org-file-properties)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2012
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2013 (defgroup org-agenda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2014 "Options concerning agenda views in Org-mode."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2015 :tag "Org Agenda"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2016 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2017
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2018 (defvar org-category nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2019 "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
2020 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
2021
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2022 # -*- mode: org; org-category: \"ELisp\"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2023
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2024 or contain a special line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2025
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2026 #+CATEGORY: ELisp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2027
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2028 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
2029 is used instead.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2030 (make-variable-buffer-local 'org-category)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
2031 (put 'org-category 'safe-local-variable '(lambda (x) (or (symbolp x) (stringp x))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2032
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2033 (defcustom org-agenda-files nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2034 "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
2035 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
2036 \\[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
2037
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2038 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
2039 `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
2040
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2041 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
2042 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
2043 agenda file per line."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2044 :group 'org-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2045 :type '(choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2046 (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
2047 (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
2048
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2049 (defcustom org-agenda-file-regexp "\\`[^.].*\\.org\\'"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2050 "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
2051 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
2052 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
2053 regular expression will be included."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2054 :group 'org-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2055 :type 'regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2056
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2057 (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
2058 "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
2059 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
2060 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
2061 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
2062 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
2063 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
2064 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
2065 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
2066 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
2067 scope."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2068 :group 'org-agenda
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2069 :type '(set :greedy t
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2070 (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
2071 (repeat :inline t (file))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2072
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2073 (if (fboundp 'defvaralias)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2074 (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
2075 '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
2076
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2077 (defcustom org-agenda-skip-unavailable-files nil
96490
2bab01f9c7bb * org.el (org-agenda-skip-unavailable-files):
Juanma Barranquero <lekktu@gmail.com>
parents: 96059
diff changeset
2078 "Non-nil means to just skip non-reachable files in `org-agenda-files'.
2bab01f9c7bb * org.el (org-agenda-skip-unavailable-files):
Juanma Barranquero <lekktu@gmail.com>
parents: 96059
diff changeset
2079 A nil value means to remove them, after a query, from the list."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2080 :group 'org-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2081 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2082
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2083 (defcustom org-calendar-to-agenda-key [?c]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2084 "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
2085 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
2086 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
2087 forth between agenda and calendar."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2088 :group 'org-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2089 :type 'sexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2090
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2091 (defcustom org-calendar-agenda-action-key [?k]
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2092 "The key to be installed in `calendar-mode-map' for agenda-action.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2093 The command `org-agenda-action' will be bound to this key. The
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2094 default is the character `k' because we use the same key in the agenda."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2095 :group 'org-agenda
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2096 :type 'sexp)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2097
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2098 (eval-after-load "calendar"
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2099 '(progn
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2100 (org-defkey calendar-mode-map org-calendar-to-agenda-key
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2101 'org-calendar-goto-agenda)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2102 (org-defkey calendar-mode-map org-calendar-agenda-action-key
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2103 'org-agenda-action)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2104
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2105 (defgroup org-latex nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2106 "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
2107 :tag "Org LaTeX"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2108 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2109
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2110 (defcustom org-format-latex-options
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2111 '(:foreground default :background default :scale 1.0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2112 :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
2113 :matchers ("begin" "$" "$$" "\\(" "\\["))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2114 "Options for creating images from LaTeX fragments.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2115 This is a property list with the following properties:
94764
b0f118394bb4 (org-modules, org-format-latex-options): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 94749
diff changeset
2116 :foreground the foreground color for images embedded in Emacs, e.g. \"Black\".
b0f118394bb4 (org-modules, org-format-latex-options): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 94749
diff changeset
2117 `default' means use the foreground of the default face.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2118 :background the background color, or \"Transparent\".
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2119 `default' means use the background of the default face.
94764
b0f118394bb4 (org-modules, org-format-latex-options): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 94749
diff changeset
2120 :scale a scaling factor for the size of the images.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2121 :html-foreground, :html-background, :html-scale
94764
b0f118394bb4 (org-modules, org-format-latex-options): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 94749
diff changeset
2122 the same numbers for HTML export.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2123 :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
2124 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
2125 \"begin\" find environments
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2126 \"$\" find math expressions surrounded by $...$
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2127 \"$$\" find math expressions surrounded by $$....$$
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2128 \"\\(\" find math expressions surrounded by \\(...\\)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2129 \"\\ [\" find math expressions surrounded by \\ [...\\]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2130 :group 'org-latex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2131 :type 'plist)
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 (defcustom org-format-latex-header "\\documentclass{article}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2134 \\usepackage{fullpage} % do not remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2135 \\usepackage{amssymb}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2136 \\usepackage[usenames]{color}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2137 \\usepackage{amsmath}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2138 \\usepackage{latexsym}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2139 \\usepackage[mathscr]{eucal}
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2140 \\pagestyle{empty} % do not remove"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2141 "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
2142 :group 'org-latex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2143 :type 'string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2144
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2145
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2146 (defgroup org-font-lock nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2147 "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
2148 :tag "Org Font Lock"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2149 :group 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2150
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2151 (defcustom org-level-color-stars-only nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2152 "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
2153 When nil, the entire headline is fontified.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2154 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
2155 also in regions already fontified."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2156 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2157 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2158
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2159 (defcustom org-hide-leading-stars nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2160 "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
2161 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
2162 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
2163 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
2164 make this work.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2165 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
2166 also in regions already fontified.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2167 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
2168 lines to the buffer:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2169
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2170 #+STARTUP: hidestars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2171 #+STARTUP: showstars"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2172 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2173 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2174
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2175 (defcustom org-fontify-done-headline nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2176 "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
2177 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
2178 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
2179 `org-headline-done' as an additional indication."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2180 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2181 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2182
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2183 (defcustom org-fontify-emphasized-text t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2184 "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
2185 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
2186 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2187 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2188
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2189 (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
2190 "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
2191 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2192 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2193
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2194 (defcustom org-hide-emphasis-markers nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2195 "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
2196 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2197 :type 'boolean)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2198
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2199 (defvar org-emph-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2200 "Regular expression for matching emphasis.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2201 (defvar org-verbatim-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2202 "Regular expression for matching verbatim text.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2203 (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
2204 (defvar org-emphasis-alist) ; defined just below
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2205 (defun org-set-emph-re (var val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2206 "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
2207 (set var val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2208 (when (and (boundp 'org-emphasis-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2209 (boundp 'org-emphasis-regexp-components)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2210 org-emphasis-alist org-emphasis-regexp-components)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2211 (let* ((e org-emphasis-regexp-components)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2212 (pre (car e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2213 (post (nth 1 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2214 (border (nth 2 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2215 (body (nth 3 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2216 (nl (nth 4 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2217 (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
2218 (body1 (concat body "*?"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2219 (markers (mapconcat 'car org-emphasis-alist ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2220 (vmarkers (mapconcat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2221 (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
2222 org-emphasis-alist "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2223 ;; 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
2224 (if (string-match "\\^" markers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2225 (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
2226 (if (string-match "-" markers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2227 (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
2228 (if (string-match "\\^" vmarkers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2229 (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
2230 (if (string-match "-" vmarkers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2231 (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
2232 (if (> nl 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2233 (setq body1 (concat body1 "\\(?:\n" body "*?\\)\\{0,"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2234 (int-to-string nl) "\\}")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2235 ;; Make the regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2236 (setq org-emph-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2237 (concat "\\([" pre (if (and nil stacked) markers) "]\\|^\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2238 "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2239 "\\([" markers "]\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2240 "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2241 "[^" border "]\\|"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2242 "[^" border (if (and nil stacked) markers) "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2243 body1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2244 "[^" border (if (and nil stacked) markers) "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2245 "\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2246 "\\3\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2247 "\\([" post (if (and nil stacked) markers) "]\\|$\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2248 (setq org-verbatim-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2249 (concat "\\([" pre "]\\|^\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2250 "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2251 "\\([" vmarkers "]\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2252 "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2253 "[^" border "]\\|"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2254 "[^" border "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2255 body1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2256 "[^" border "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2257 "\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2258 "\\3\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2259 "\\([" post "]\\|$\\)")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2260
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2261 (defcustom org-emphasis-regexp-components
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2262 '(" \t('\"" "- \t.,:?;'\")" " \t\r\n,\"'" "." 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2263 "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
2264 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
2265 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
2266 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
2267 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
2268 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
2269
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2270 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
2271 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
2272 border The chars *forbidden* as border characters.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2273 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
2274 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
2275 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
2276
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2277 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
2278 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2279 :set 'org-set-emph-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2280 :type '(list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2281 (sexp :tag "Allowed chars in pre ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2282 (sexp :tag "Allowed chars in post ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2283 (sexp :tag "Forbidden chars in border ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2284 (sexp :tag "Regexp for body ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2285 (integer :tag "number of newlines allowed")
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2286 (option (boolean :tag "Please ignore this button"))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2287
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2288 (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
2289 `(("*" bold "<b>" "</b>")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2290 ("/" italic "<i>" "</i>")
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
2291 ("_" underline "<span style=\"text-decoration:underline;\">" "</span>")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2292 ("=" org-code "<code>" "</code>" verbatim)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
2293 ("~" org-verbatim "<code>" "</code>" verbatim)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2294 ("+" ,(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
2295 "<del>" "</del>")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2296 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2297 "Special syntax for emphasized text.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2298 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
2299 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
2300 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
2301 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
2302 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
2303 :group 'org-font-lock
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2304 :set 'org-set-emph-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2305 :type '(repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2306 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2307 (string :tag "Marker character")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2308 (choice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2309 (face :tag "Font-lock-face")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2310 (plist :tag "Face property list"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2311 (string :tag "HTML start tag")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2312 (string :tag "HTML end tag")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2313 (option (const verbatim)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2314
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2315 ;;; Miscellaneous options
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 (defgroup org-completion nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2318 "Completion in Org-mode."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2319 :tag "Org Completion"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2320 :group 'org)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2321
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2322 (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
2323 "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
2324 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
2325 :group 'org-completion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2326 :type 'function)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2327
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2328 ;;; Functions and variables from ther packages
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2329 ;; Declared here to avoid compiler warnings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2330
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2331 ;; XEmacs only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2332 (defvar outline-mode-menu-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2333 (defvar outline-mode-menu-show)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2334 (defvar outline-mode-menu-hide)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2335 (defvar zmacs-regions) ; XEmacs regions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2336
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2337 ;; Emacs only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2338 (defvar mark-active)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2339
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2340 ;; Various packages
94457
79f15639a32a (calendar-absolute-from-iso, calendar-iso-from-absolute): Fix declarations.
Glenn Morris <rgm@gnu.org>
parents: 94414
diff changeset
2341 (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
2342 (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
2343 (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
2344 (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
2345 (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
2346 (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
2347 (defvar calc-embedded-open-formula)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2348 (declare-function cdlatex-tab "ext:cdlatex" ())
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2349 (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
2350 (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
2351 (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
2352 (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
2353 (defvar iswitchb-temp-buflist)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2354 (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
2355 (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
2356 (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
2357 (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
2358 (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
2359 (declare-function org-agenda-change-all-lines "org-agenda"
99717
f6ad8a3462f6 (org-agenda-change-all-lines): Fix declaration.
Glenn Morris <rgm@gnu.org>
parents: 99690
diff changeset
2360 (newhead hdmarker &optional fixface just-this))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2361 (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
2362 (declare-function org-agenda-maybe-redo "org-agenda" ())
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2363 (declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2364 (beg end))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2365 (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
2366 (declare-function remember "remember" (&optional initial))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2367 (declare-function remember-buffer-desc "remember" ())
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2368 (declare-function remember-finalize "remember" ())
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2369 (defvar remember-save-after-remembering)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2370 (defvar remember-data-file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2371 (defvar remember-register)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2372 (defvar remember-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2373 (defvar remember-handler-functions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2374 (defvar remember-annotation-functions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2375 (defvar texmathp-why)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2376 (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
2377 (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
2378
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2379 (defvar w3m-current-url)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2380 (defvar w3m-current-title)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2381
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2382 (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
2383
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2384 ;;; 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
2385
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2386 ;; 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
2387 ;; 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
2388
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2389 (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
2390 "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
2391 (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
2392 "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
2393 (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
2394 "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
2395 (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
2396 "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
2397 (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
2398 "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
2399 (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
2400 "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
2401 outside the table.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2402
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2403 ;; 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
2404
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2405 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2406 (org-autoload "org-table"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2407 '(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
2408 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
2409 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
2410 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
2411 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
2412 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
2413 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
2414 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
2415 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
2416 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
2417 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
2418 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
2419 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
2420 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
2421 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
2422 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
2423 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
2424 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
2425 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
2426 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
2427 org-table-toggle-formula-debugger org-table-wrap-region
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
2428 orgtbl-mode turn-on-orgtbl org-table-to-lisp)))
94414
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 (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
2431 "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
2432 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
2433 (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
2434 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2435 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2436 (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
2437 org-table-line-regexp)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2438 nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2439 (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
2440
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2441 (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
2442 "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
2443 (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
2444 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2445 (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
2446 (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
2447 (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
2448 "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
2449 (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
2450 (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
2451 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2452 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2453 (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
2454 nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2455 (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
2456 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2457 (beginning-of-line 2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2458 (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
2459 (beginning-of-line -1)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2460 (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
2461 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2462 (require 'table)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2463 (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
2464 t
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2465 (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
2466 (table-recognize-table)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2467 (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
2468 (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
2469 t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2470 nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2471 nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2472
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2473 (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
2474 "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
2475 (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
2476 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2477 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2478 (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
2479 nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2480
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2481 (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
2482
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2483 (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
2484 "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
2485 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2486 (save-restriction
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2487 (widen)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2488 (goto-char (point-min))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2489 (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
2490 (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
2491 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2492 (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
2493 (save-excursion (funcall function)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2494 (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
2495 (message "Mapping tables: done"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2496
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2497 ;; 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
2498
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2499 (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
2500 (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
2501 (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
2502 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2503 (org-autoload "org-exp"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2504 '(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
2505 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
2506 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
2507 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
2508 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
2509 org-export-icalendar-all-agenda-files
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2510 org-table-clean-before-export
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2511 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
2512
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
2513 ;; Declare and autoload functions from org-agenda.el
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2514
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2515 (eval-and-compile
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
2516 (org-autoload "org-agenda"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2517 '(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
2518 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
2519 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
2520
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2521 ;; Autoload org-remember
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2522
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2523 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2524 (org-autoload "org-remember"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2525 '(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
2526 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
2527
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2528 ;; Autoload org-clock.el
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2529
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2530
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2531 (declare-function org-clock-save-markers-for-cut-and-paste "org-clock"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2532 (beg end))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2533 (declare-function org-update-mode-line "org-clock" ())
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2534 (defvar org-clock-start-time)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2535 (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
2536 "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
2537
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2538 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2539 (org-autoload
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2540 "org-clock"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2541 '(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
2542 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
2543 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
2544 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
2545 org-get-clocktable)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2546
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2547 (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
2548 "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
2549 Otherwise, return nil."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2550 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2551 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2552 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2553 (skip-chars-forward " \t")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2554 (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
2555 (let ((re (concat "[ \t]*" org-clock-string
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2556 " *[[<]\\([^]>]+\\)[]>]\\(-+[[<]\\([^]>]+\\)[]>]"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2557 "\\([ \t]*=>.*\\)?\\)?"))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
2558 ts te h m s neg)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2559 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2560 ((not (looking-at re))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2561 nil)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2562 ((not (match-end 2))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2563 (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2564 (> org-clock-marker (point))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2565 (<= org-clock-marker (point-at-eol)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2566 ;; The clock is running here
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2567 (setq org-clock-start-time
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
2568 (apply 'encode-time
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2569 (org-parse-time-string (match-string 1))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2570 (org-update-mode-line)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2571 (t
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2572 (and (match-end 4) (delete-region (match-beginning 4) (match-end 4)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2573 (end-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2574 (setq ts (match-string 1)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2575 te (match-string 3))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2576 (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
2577 (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
2578 (time-to-seconds
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2579 (apply 'encode-time (org-parse-time-string ts))))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
2580 neg (< s 0)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
2581 s (abs s)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2582 h (floor (/ s 3600))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2583 s (- s (* 3600 h))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2584 m (floor (/ s 60))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2585 s (- s (* 60 s)))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
2586 (insert " => " (format (if neg "-%d:%02d" "%2d:%02d") h m))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2587 t))))))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2588
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2589 (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
2590 "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
2591 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
2592 (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
2593 (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
2594 (buffer-name))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2595 (org-clock-out)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2596 (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
2597 (save-buffer))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2598
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2599 (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
2600 "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
2601 (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
2602 (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
2603
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2604 ;; Autoload archiving code
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2605 ;; 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
2606
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2607 (defgroup org-archive nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2608 "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
2609 :tag "Org Archive"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2610 :group 'org-structure)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2611
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2612 (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
2613 "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
2614
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2615 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
2616 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
2617
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2618 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
2619 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
2620 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
2621 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
2622
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2623 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
2624 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
2625 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
2626
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2627 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
2628 \"%s_archive::\"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2629 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
2630 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
2631
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2632 \"::* Archived Tasks\"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2633 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
2634 \"* Archived Tasks\".
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2635
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2636 \"~/org/archive.org::\"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2637 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
2638
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2639 \"basement::** Finished Tasks\"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2640 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
2641 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
2642
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2643 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
2644 line like
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2645
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2646 #+ARCHIVE: basement::** Finished Tasks
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2647
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2648 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
2649 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
2650 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
2651 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2652 :type 'string)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2653
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2654 (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
2655 "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
2656 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
2657 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
2658 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
2659 get the proper fontification."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2660 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2661 :group 'org-keywords
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2662 :type 'string)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2663
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2664 (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
2665 "Non-nil means, the agenda will skip any items located in archived trees.
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
2666 An archived tree is a tree marked with the tag ARCHIVE. The use of this
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
2667 variable is no longer recommended, you should leave it at the value t.
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
2668 Instead, use the key `v' to cycle the archives-mode in the agenda."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2669 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2670 :group 'org-agenda-skip
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2671 :type 'boolean)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2672
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2673 (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
2674 "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
2675 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
2676 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
2677 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
2678 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2679 :group 'org-cycle
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2680 :type 'boolean)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2681
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2682 (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
2683 "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
2684 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
2685 collapsed state."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2686 :group 'org-archive
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2687 :group 'org-sparse-trees
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2688 :type 'boolean)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2689
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2690 (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
2691 "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
2692 (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
2693 (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
2694 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2695 (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
2696 (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
2697 (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
2698 (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
2699 (goto-char beg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2700 (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
2701 (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
2702 "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
2703
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2704 (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
2705 "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
2706 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2707 (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
2708 (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
2709 (call-interactively 'org-cycle)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2710
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2711 (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
2712 "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
2713 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2714 (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
2715 (goto-char beg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2716 (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
2717 (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
2718 (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
2719
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2720 (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
2721
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2722 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2723 (org-autoload "org-archive"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2724 '(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
2725 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
2726
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2727 ;; Autoload Column View Code
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2728
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2729 (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
2730 (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
2731 (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
2732
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2733 (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
2734 '(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
2735 org-columns-compute org-agenda-columns org-columns-remove-overlays
97027
adc2dffbdfc3 2008-07-25 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96975
diff changeset
2736 org-columns org-insert-columns-dblock org-dblock-write:columnview))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2737
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2738 ;; Autoload ID code
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2739
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2740 (org-autoload "org-id"
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
2741 '(org-id-get-create org-id-new org-id-copy org-id-get
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
2742 org-id-get-with-outline-path-completion
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2743 org-id-get-with-outline-drilling
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2744 org-id-goto org-id-find))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2745
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2746 ;;; 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
2747
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2748 (defvar org-drawer-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2749 "Matches first line of a hidden block.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2750 (make-variable-buffer-local 'org-drawer-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2751 (defvar org-todo-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2752 "Matches any of the TODO state keywords.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2753 (make-variable-buffer-local 'org-todo-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2754 (defvar org-not-done-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2755 "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
2756 (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
2757 (defvar org-todo-line-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2758 "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
2759 (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
2760 (defvar org-complex-heading-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2761 "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
2762 group 1: the stars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2763 group 2: The todo keyword, maybe
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2764 group 3: Priority cookie
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2765 group 4: True headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2766 group 5: Tags")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2767 (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
2768 (defvar org-todo-line-tags-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2769 "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
2770 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
2771 (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
2772 (defvar org-nl-done-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2773 "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
2774 (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
2775 (defvar org-looking-at-done-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2776 "Matches the DONE keyword a point.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2777 (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
2778 (defvar org-ds-keyword-length 12
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2779 "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
2780 (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
2781 (defvar org-deadline-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2782 "Matches the DEADLINE keyword.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2783 (make-variable-buffer-local 'org-deadline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2784 (defvar org-deadline-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2785 "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
2786 (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
2787 (defvar org-deadline-line-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2788 "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
2789 (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
2790 (defvar org-scheduled-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2791 "Matches the SCHEDULED keyword.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2792 (make-variable-buffer-local 'org-scheduled-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2793 (defvar org-scheduled-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2794 "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
2795 (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
2796 (defvar org-closed-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2797 "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
2798 (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
2799
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2800 (defvar org-keyword-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2801 "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
2802 (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
2803 (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
2804 "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
2805 (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
2806 (defvar org-maybe-keyword-time-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2807 "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
2808 (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
2809 (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
2810 "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
2811 (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
2812
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2813 (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
2814 (concat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2815 "\\(\\<[012]?[0-9]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2816 "\\(\\(:\\([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
2817 "\\(--?"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2818 "\\(\\<[012]?[0-9]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2819 "\\(\\(:\\([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
2820 "\\)?")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2821 "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
2822 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
2823 groups carry important information:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2824 0 the full match
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2825 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
2826 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
2827
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2828 (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
2829 (concat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2830 "\\(\\<[012]?[0-9]"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2831 "\\(\\(:\\([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
2832 "\\+\\([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
2833 "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
2834 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
2835 groups carry important information:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2836 0 the full match
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2837 7 hours of duration
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2838 9 minutes of duration")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2839
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2840 (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
2841 (concat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2842 "<\\([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
2843 "\\([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
2844 "\\(--?"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2845 "<\\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
2846 "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
2847 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
2848 0 the full match
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
2849 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
2850 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
2851 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
2852
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2853 (defconst org-startup-options
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2854 '(("fold" org-startup-folded t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2855 ("overview" org-startup-folded t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2856 ("nofold" org-startup-folded nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2857 ("showall" org-startup-folded nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2858 ("content" org-startup-folded content)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2859 ("hidestars" org-hide-leading-stars t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2860 ("showstars" org-hide-leading-stars nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2861 ("odd" org-odd-levels-only t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2862 ("oddeven" org-odd-levels-only nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2863 ("align" org-startup-align-all-tables t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2864 ("noalign" org-startup-align-all-tables nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2865 ("customtime" org-display-custom-times t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2866 ("logdone" org-log-done time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2867 ("lognotedone" org-log-done note)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2868 ("nologdone" org-log-done nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2869 ("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
2870 ("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
2871 ("logrepeat" org-log-repeat state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2872 ("lognoterepeat" org-log-repeat note)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2873 ("nologrepeat" org-log-repeat nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2874 ("constcgs" constants-unit-system cgs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2875 ("constSI" constants-unit-system SI))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2876 "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
2877 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
2878 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
2879 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
2880 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
2881
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2882 (defun org-set-regexps-and-options ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2883 "Precompute regular expressions for current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2884 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2885 (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
2886 (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
2887 (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
2888 (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
2889 (org-set-local 'org-done-keywords nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2890 (org-set-local 'org-todo-heads nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2891 (org-set-local 'org-todo-sets nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2892 (org-set-local 'org-todo-log-states nil)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2893 (org-set-local 'org-file-properties nil)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2894 (org-set-local 'org-file-tags nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2895 (let ((re (org-make-options-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2896 '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "COLUMNS"
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2897 "STARTUP" "ARCHIVE" "FILETAGS" "TAGS" "LINK" "PRIORITIES"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2898 "CONSTANTS" "PROPERTY" "DRAWERS" "SETUPFILE")))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2899 (splitre "[ \t]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2900 kwds kws0 kwsa key log value cat arch tags const links hw dws
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2901 tail sep kws1 prio props ftags drawers
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2902 ext-setup-or-nil setup-contents (start 0))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2903 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2904 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2905 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2906 (goto-char (point-min))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2907 (while (or (and ext-setup-or-nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2908 (string-match re ext-setup-or-nil start)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2909 (setq start (match-end 0)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2910 (and (setq ext-setup-or-nil nil start 0)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2911 (re-search-forward re nil t)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2912 (setq key (upcase (match-string 1 ext-setup-or-nil))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2913 value (org-match-string-no-properties 2 ext-setup-or-nil))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2914 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2915 ((equal key "CATEGORY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2916 (if (string-match "[ \t]+$" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2917 (setq value (replace-match "" t t value)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2918 (setq cat value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2919 ((member key '("SEQ_TODO" "TODO"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2920 (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
2921 ((equal key "TYP_TODO")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2922 (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
2923 ((equal key "TAGS")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2924 (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
2925 ((equal key "COLUMNS")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2926 (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
2927 ((equal key "LINK")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2928 (when (string-match "^\\(\\S-+\\)[ \t]+\\(.+\\)" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2929 (push (cons (match-string 1 value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2930 (org-trim (match-string 2 value)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2931 links)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2932 ((equal key "PRIORITIES")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2933 (setq prio (org-split-string value " +")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2934 ((equal key "PROPERTY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2935 (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2936 (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
2937 props)))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2938 ((equal key "FILETAGS")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2939 (when (string-match "\\S-" value)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2940 (setq ftags
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2941 (append
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2942 ftags
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2943 (apply 'append
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2944 (mapcar (lambda (x) (org-split-string x ":"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2945 (org-split-string value)))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2946 ((equal key "DRAWERS")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2947 (setq drawers (org-split-string value splitre)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2948 ((equal key "CONSTANTS")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2949 (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
2950 ((equal key "STARTUP")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2951 (let ((opts (org-split-string value splitre))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2952 l var val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2953 (while (setq l (pop opts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2954 (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
2955 (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
2956 (if (not (nth 3 l))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2957 (set (make-local-variable var) val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2958 (if (not (listp (symbol-value var)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2959 (set (make-local-variable var) nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2960 (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
2961 (add-to-list var val))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2962 ((equal key "ARCHIVE")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2963 (string-match " *$" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2964 (setq arch (replace-match "" t t value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2965 (remove-text-properties 0 (length arch)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2966 '(face t fontified t) arch))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2967 ((equal key "SETUPFILE")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2968 (setq setup-contents (org-file-contents
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2969 (expand-file-name
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2970 (org-remove-double-quotes value))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2971 'noerror))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2972 (if (not ext-setup-or-nil)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2973 (setq ext-setup-or-nil setup-contents start 0)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2974 (setq ext-setup-or-nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2975 (concat (substring ext-setup-or-nil 0 start)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2976 "\n" setup-contents "\n"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2977 (substring ext-setup-or-nil start)))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2978 ))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2979 (when cat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2980 (org-set-local 'org-category (intern cat))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2981 (push (cons "CATEGORY" cat) props))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2982 (when prio
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2983 (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
2984 (setq prio (mapcar 'string-to-char prio))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2985 (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
2986 (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
2987 (org-set-local 'org-default-priority (nth 2 prio)))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2988 (and props (org-set-local 'org-file-properties (nreverse props)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
2989 (and ftags (org-set-local 'org-file-tags ftags))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2990 (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
2991 (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
2992 (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
2993 ;; Process the TODO keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2994 (unless kwds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2995 ;; 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
2996 (setq kwds (default-value 'org-todo-keywords))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2997 (if (stringp (car kwds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2998 (setq kwds (list (cons org-todo-interpretation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2999 (default-value 'org-todo-keywords)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3000 (setq kwds (reverse kwds)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3001 (setq kwds (nreverse kwds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3002 (let (inter kws kw)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3003 (while (setq kws (pop kwds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3004 (setq inter (pop kws) sep (member "|" kws)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3005 kws0 (delete "|" (copy-sequence kws))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3006 kwsa nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3007 kws1 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3008 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3009 ;; 1 2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3010 (if (string-match "^\\(.*?\\)\\(?:(\\([^!@/]\\)?.*?)\\)?$" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3011 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3012 (setq kw (match-string 1 x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3013 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
3014 log (org-extract-log-state-settings x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3015 (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
3016 (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
3017 kw)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3018 (error "Invalid TODO keyword %s" x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3019 kws0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3020 kwsa (if kwsa (append '((:startgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3021 (nreverse kwsa)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3022 '((:endgroup))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3023 hw (car kws1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3024 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
3025 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
3026 (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
3027 (push kws1 org-todo-sets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3028 (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
3029 (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
3030 (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
3031 (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
3032 (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
3033 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
3034 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
3035 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
3036 ;; Process the constants
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3037 (when const
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3038 (let (e cst)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3039 (while (setq e (pop const))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3040 (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
3041 (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
3042 (setq org-table-formula-constants-local cst)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3043
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3044 ;; Process the tags.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3045 (when tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3046 (let (e tgs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3047 (while (setq e (pop tags))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3048 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3049 ((equal e "{") (push '(:startgroup) tgs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3050 ((equal e "}") (push '(:endgroup) tgs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3051 ((string-match (org-re "^\\([[:alnum:]_@]+\\)(\\(.\\))$") e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3052 (push (cons (match-string 1 e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3053 (string-to-char (match-string 2 e)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3054 tgs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3055 (t (push (list e) tgs))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3056 (org-set-local 'org-tag-alist nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3057 (while (setq e (pop tgs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3058 (or (and (stringp (car e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3059 (assoc (car e) org-tag-alist))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3060 (push e org-tag-alist)))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3061
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3062 ;; Compute the regular expressions and other local variables
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3063 (if (not org-done-keywords)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3064 (setq org-done-keywords (list (org-last org-todo-keywords-1))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3065 (setq org-ds-keyword-length (+ 2 (max (length org-deadline-string)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3066 (length org-scheduled-string)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3067 (length org-clock-string)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3068 (length org-closed-string)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3069 org-drawer-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3070 (concat "^[ \t]*:\\("
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3071 (mapconcat 'regexp-quote org-drawers "\\|")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3072 "\\):[ \t]*$")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3073 org-not-done-keywords
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3074 (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3075 org-todo-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3076 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3077 "\\|") "\\)\\>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3078 org-not-done-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3079 (concat "\\<\\("
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3080 (mapconcat 'regexp-quote org-not-done-keywords "\\|")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3081 "\\)\\>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3082 org-todo-line-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3083 (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3084 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3085 "\\)\\>\\)?[ \t]*\\(.*\\)")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3086 org-complex-heading-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3087 (concat "^\\(\\*+\\)\\(?:[ \t]+\\("
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3088 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3089 "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3090 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3091 org-nl-done-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3092 (concat "\n\\*+[ \t]+"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3093 "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3094 "\\)" "\\>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3095 org-todo-line-tags-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3096 (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3097 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3098 (org-re
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3099 "\\)\\>\\)? *\\(.*?\\([ \t]:[[:alnum:]:_@]+:[ \t]*\\)?$\\)"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3100 org-looking-at-done-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3101 (concat "^" "\\(?:"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3102 (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3103 "\\>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3104 org-deadline-regexp (concat "\\<" org-deadline-string)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3105 org-deadline-time-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3106 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3107 org-deadline-line-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3108 (concat "\\<\\(" org-deadline-string "\\).*")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3109 org-scheduled-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3110 (concat "\\<" org-scheduled-string)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3111 org-scheduled-time-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3112 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3113 org-closed-time-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3114 (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3115 org-keyword-time-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3116 (concat "\\<\\(" org-scheduled-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3117 "\\|" org-deadline-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3118 "\\|" org-closed-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3119 "\\|" org-clock-string "\\)"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3120 " *[[<]\\([^]>]+\\)[]>]")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3121 org-keyword-time-not-clock-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3122 (concat "\\<\\(" org-scheduled-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3123 "\\|" org-deadline-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3124 "\\|" org-closed-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3125 "\\)"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3126 " *[[<]\\([^]>]+\\)[]>]")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3127 org-maybe-keyword-time-regexp
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3128 (concat "\\(\\<\\(" org-scheduled-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3129 "\\|" org-deadline-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3130 "\\|" org-closed-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3131 "\\|" org-clock-string "\\)\\)?"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3132 " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3133 org-planning-or-clock-line-re
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3134 (concat "\\(?:^[ \t]*\\(" org-scheduled-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3135 "\\|" org-deadline-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3136 "\\|" org-closed-string "\\|" org-clock-string
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3137 "\\)\\>\\)")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3138 )
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3139 (org-compute-latex-and-specials-regexp)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3140 (org-set-font-lock-defaults))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3141
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3142 (defun org-file-contents (file &optional noerror)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3143 "Return the contents of FILE, as a string."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3144 (if (or (not file)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3145 (not (file-readable-p file)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3146 (if noerror
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3147 (progn
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3148 (message "Cannot read file %s" file)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3149 (ding) (sit-for 2)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3150 "")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3151 (error "Cannot read file %s" file))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3152 (with-temp-buffer
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3153 (insert-file-contents file)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3154 (buffer-string))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3155
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3156 (defun org-extract-log-state-settings (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3157 "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
3158 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
3159 (let (kw key log1 log2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3160 (when (string-match "^\\(.*?\\)\\(?:(\\([^!@/]\\)?\\([!@]\\)?\\(?:/\\([!@]\\)\\)?)\\)?$" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3161 (setq kw (match-string 1 x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3162 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
3163 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
3164 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
3165 (and (or log1 log2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3166 (list kw
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3167 (and log1 (if (equal log1 "!") 'time 'note))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3168 (and log2 (if (equal log2 "!") 'time 'note)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3169
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3170 (defun org-remove-keyword-keys (list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3171 "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
3172 (mapcar (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3173 (if (string-match "(.*)$" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3174 (substring x 0 (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3175 x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3176 list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3177
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3178 ;; 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
3179 (defun org-assign-fast-keys (alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3180 "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
3181 Respect keys that are already there."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3182 (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
3183 (while (setq e (pop alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3184 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3185 ((equal e '(:startgroup)) (push e new))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3186 ((equal e '(:endgroup)) (push e new))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3187 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3188 (setq k (car e) c2 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3189 (if (cdr e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3190 (setq c (cdr e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3191 ;; automatically assign a character.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3192 (setq c1 (string-to-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3193 (downcase (substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3194 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
3195 (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
3196 (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
3197 (setq char (1+ char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3198 (setq c2 c1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3199 (setq c (or c2 char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3200 (push (cons k c) new))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3201 (nreverse new)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3202
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3203 ;;; Some variables used in various places
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3204
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3205 (defvar org-window-configuration nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3206 "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
3207 (defvar org-finish-function nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3208 "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
3209 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
3210
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3211
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3212 ;; 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
3213 ;; 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
3214 (defvar entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3215 (defvar state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3216 (defvar last-state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3217 (defvar date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3218 (defvar description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3219
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3220 ;; 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
3221 (defvar org-html-entities)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3222 (defvar org-struct-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3223 (defvar org-org-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3224 (defvar org-tbl-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3225 (defvar org-agenda-keymap)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3226
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3227 ;;;; Define the Org-mode
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 (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
3230 (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
3231
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3232
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3233 ;; 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
3234 ;; an update.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3235 (defvar org-table-may-need-update t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3236 "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
3237 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
3238 `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
3239 (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
3240 "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
3241 (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
3242 (defvar org-mode-map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3243 (defvar org-mode-hook nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3244 (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
3245 (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
3246 (defvar org-table-buffer-is-an nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3247 (defconst org-outline-regexp "\\*+ ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3248
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3249 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3250 (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
3251 "Outline-based notes management and organizer, alias
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3252 \"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
3253
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3254 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
3255 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
3256 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
3257 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
3258 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
3259 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
3260 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
3261 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
3262 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
3263 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
3264
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3265 The following commands are available:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3266
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3267 \\{org-mode-map}"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3268
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3269 ;; 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
3270 ;; 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
3271 ;; 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
3272 ;; we switch another buffer into org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3273 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3274 (when (boundp 'outline-mode-menu-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3275 ;; 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
3276 (easy-menu-remove outline-mode-menu-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3277 (easy-menu-remove outline-mode-menu-show)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3278 (easy-menu-remove outline-mode-menu-hide))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3279 (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
3280 (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
3281 (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
3282
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3283 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3284 (easy-menu-add org-org-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3285 (easy-menu-add org-tbl-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3286 (org-install-agenda-files-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3287 (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
3288 (org-add-to-invisibility-spec '(org-cwidth))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3289 (when (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3290 (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
3291 (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
3292 (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
3293 (when (and org-ellipsis
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3294 (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
3295 (fboundp 'make-glyph-code))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3296 (unless org-display-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3297 (setq org-display-table (make-display-table)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3298 (set-display-table-slot
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3299 org-display-table 4
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3300 (vconcat (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3301 (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
3302 org-ellipsis)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3303 (if (stringp org-ellipsis) org-ellipsis "..."))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3304 (setq buffer-display-table org-display-table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3305 (org-set-regexps-and-options)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3306 ;; Calc embedded
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3307 (org-set-local 'calc-embedded-open-mode "# ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3308 (modify-syntax-entry ?# "<")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3309 (modify-syntax-entry ?@ "w")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3310 (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
3311 (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
3312 'org-unfontify-region)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3313 ;; Activate before-change-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3314 (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
3315 (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
3316 'local)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3317 ;; 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
3318 (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
3319 ;; Paragraphs and auto-filling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3320 (org-set-autofill-regexps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3321 (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
3322 (org-update-radio-target-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3323
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3324 ;; Comment characters
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3325 ; (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
3326 (org-set-local 'comment-padding " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3327
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3328 ;; Align options lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3329 (org-set-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3330 'align-mode-rules-list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3331 '((org-in-buffer-settings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3332 (regexp . "^#\\+[A-Z_]+:\\(\\s-*\\)\\S-+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3333 (modes . '(org-mode)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3334
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3335 ;; Imenu
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3336 (org-set-local 'imenu-create-index-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3337 'org-imenu-get-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3338
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3339 ;; Make isearch reveal context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3340 (if (or (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3341 (not (boundp 'outline-isearch-open-invisible-function)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3342 ;; 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
3343 (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
3344 ;; 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
3345 (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
3346 (lambda (&rest ignore) (org-show-context 'isearch))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3347
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3348 ;; 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
3349 (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
3350 (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3351 (= (point-min) (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3352 (insert "# -*- mode: org -*-\n\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3353
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3354 (unless org-inhibit-startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3355 (when org-startup-align-all-tables
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3356 (let ((bmp (buffer-modified-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3357 (org-table-map-tables 'org-table-align)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3358 (set-buffer-modified-p bmp)))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3359 (org-set-startup-visibility)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3360
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3361 (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
3362
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3363 (defun org-current-time ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3364 "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
3365 (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
3366 (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
3367 (time (decode-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3368 (apply 'encode-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3369 (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
3370 (nthcdr 2 time))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3371 (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3372
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3373 ;;;; Font-Lock stuff, including the activators
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3374
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3375 (defvar org-mouse-map (make-sparse-keymap))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3376 (org-defkey org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3377 (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
3378 (org-defkey org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3379 (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
3380 (when org-mouse-1-follows-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3381 (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
3382 (when org-tab-follows-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3383 (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
3384 (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
3385 (when org-return-follows-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3386 (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
3387 (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
3388
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3389 (require 'font-lock)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3390
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3391 (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
3392 (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
3393 "shell" "elisp"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3394 (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
3395 "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
3396 (defvar org-link-re-with-space nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3397 "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
3398 (defvar org-link-re-with-space2 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3399 "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
3400 (defvar org-angle-link-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3401 "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
3402 (defvar org-plain-link-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3403 "Matches plain link, without spaces.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3404 (defvar org-bracket-link-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3405 "Matches a link in double brackets.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3406 (defvar org-bracket-link-analytic-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3407 "Regular expression used to analyze links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3408 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
3409 1: http:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3410 2: http
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3411 3: path
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3412 4: [desc]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3413 5: desc")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3414 (defvar org-any-link-re nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3415 "Regular expression matching any link.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3416
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3417 (defun org-make-link-regexps ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3418 "Update the link regular expressions.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3419 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
3420 (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
3421 (concat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3422 "\\`\\(" (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
3423 org-link-re-with-space
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3424 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3425 "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3426 "\\([^" org-non-link-chars " ]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3427 "[^" org-non-link-chars "]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3428 "[^" org-non-link-chars " ]\\)>?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3429 org-link-re-with-space2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3430 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3431 "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3432 "\\([^" org-non-link-chars " ]"
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
3433 "[^\t\n\r]*"
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3434 "[^" org-non-link-chars " ]\\)>?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3435 org-angle-link-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3436 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3437 "<\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3438 "\\([^" org-non-link-chars " ]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3439 "[^" org-non-link-chars "]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3440 "\\)>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3441 org-plain-link-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3442 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3443 "\\<\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3444 "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3445 org-bracket-link-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3446 "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3447 org-bracket-link-analytic-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3448 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3449 "\\[\\["
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3450 "\\(\\(" (mapconcat 'identity org-link-types "\\|") "\\):\\)?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3451 "\\([^]]+\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3452 "\\]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3453 "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
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 org-any-link-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3456 (concat "\\(" org-bracket-link-regexp "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3457 org-angle-link-re "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3458 org-plain-link-re "\\)")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3459
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3460 (org-make-link-regexps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3461
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3462 (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
3463 "Regular expression for fast time stamp matching.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3464 (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
3465 "Regular expression for fast time stamp matching.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3466 (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
3467 "Regular expression matching time strings for analysis.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3468 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
3469 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
3470 (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
3471 "Regular expression matching time strings for analysis.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3472 (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
3473 "Regular expression matching time stamps, with groups.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3474 (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
3475 "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
3476 (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
3477 "Regular expression matching a time stamp range.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3478 (defconst org-tr-regexp-both
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3479 (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
3480 "Regular expression matching a time stamp range.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3481 (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
3482 org-ts-regexp "\\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3483 "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
3484 (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
3485 org-ts-regexp-both "\\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3486 "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
3487 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
3488
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3489 (defvar org-emph-face nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3490
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3491 (defun org-do-emphasis-faces (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3492 "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
3493 (let (rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3494 (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
3495 (if (not (= (char-after (match-beginning 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3496 (char-after (match-beginning 4))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3497 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3498 (setq rtn t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3499 (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
3500 'face
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3501 (nth 1 (assoc (match-string 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3502 org-emphasis-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3503 (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
3504 '(font-lock-multiline t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3505 (when org-hide-emphasis-markers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3506 (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
3507 '(invisible org-link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3508 (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
3509 '(invisible org-link)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3510 (backward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3511 rtn))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3512
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3513 (defun org-emphasize (&optional char)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3514 "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
3515 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
3516 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
3517 the cursor between them.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3518 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
3519 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
3520 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
3521 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
3522 will be prompted for."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3523 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3524 (let ((eal org-emphasis-alist) e det
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3525 (erc org-emphasis-regexp-components)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3526 (prompt "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3527 (string "") beg end move tag c s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3528 (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3529 (setq beg (region-beginning) end (region-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3530 string (buffer-substring beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3531 (setq move t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3532
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3533 (while (setq e (pop eal))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3534 (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
3535 c (aref tag 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3536 (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
3537 (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
3538 (substring tag 1)))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
3539 (setq det (nreverse det))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3540 (unless char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3541 (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
3542 (setq char (read-char-exclusive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3543 (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
3544 (if (equal char ?\ )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3545 (setq s "" move nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3546 (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
3547 (error "No such emphasis marker: \"%c\"" char))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3548 (setq s (char-to-string char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3549 (while (and (> (length string) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3550 (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
3551 (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
3552 (setq string (substring string 1 -1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3553 (setq string (concat s string s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3554 (if beg (delete-region beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3555 (unless (or (bolp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3556 (string-match (concat "[" (nth 0 erc) "\n]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3557 (char-to-string (char-before (point)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3558 (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3559 (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
3560 (char-to-string (char-after (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3561 (insert " ") (backward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3562 (insert string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3563 (and move (backward-char 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3564
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3565 (defconst org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3566 '(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
3567
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3568
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3569 (defun org-activate-plain-links (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3570 "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
3571 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3572 (let (f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3573 (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
3574 (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
3575 (if (or (eq f 'org-tag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3576 (and (listp f) (memq 'org-tag f)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3577 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3578 (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
3579 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3580 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3581 'keymap org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3582 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3583 (throw 'exit t))))))
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-activate-code (limit)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
3586 (if (re-search-forward "^[ \t]*\\(: .*\n?\\)" limit t)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
3587 (progn
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3588 (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
3589 '(display t invisible t intangible t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3590 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3591
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3592 (defun org-activate-angle-links (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3593 "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
3594 (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
3595 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3596 (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
3597 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3598 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3599 'keymap org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3600 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3601 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3602
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3603 (defun org-activate-bracket-links (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3604 "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
3605 (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
3606 (let* ((help (concat "LINK: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3607 (org-match-string-no-properties 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3608 ;; FIXME: above we should remove the escapes.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3609 ;; 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
3610 ;; a lot of overhead for font-lock.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3611 (ip (org-maybe-intangible
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3612 (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
3613 'keymap org-mouse-map 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3614 'font-lock-multiline t 'help-echo help)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3615 (vp (list 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3616 'keymap org-mouse-map 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3617 ' font-lock-multiline t 'help-echo help)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3618 ;; 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
3619 ;; may have made some of this invisible.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3620 (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
3621 '(invisible nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3622 (if (match-end 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3623 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3624 (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
3625 (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
3626 (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
3627 (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
3628 (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
3629 (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
3630 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3631
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3632 (defun org-activate-dates (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3633 "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
3634 (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
3635 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3636 (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
3637 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3638 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3639 'keymap org-mouse-map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3640 (when org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3641 (if (match-end 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3642 (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
3643 (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
3644 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3645
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3646 (defvar org-target-link-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3647 "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
3648 (defvar org-target-regexp "<<\\([^<>\n\r]+\\)>>"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3649 "Regular expression matching a link target.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3650 (defvar org-radio-target-regexp "<<<\\([^<>\n\r]+\\)>>>"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3651 "Regular expression matching a radio target.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3652 (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
3653 "Regular expression matching any target.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3654
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3655 (defun org-activate-target-links (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3656 "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
3657 (when org-target-link-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3658 (let ((case-fold-search t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3659 (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
3660 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3661 (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
3662 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3663 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3664 'keymap org-mouse-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3665 'help-echo "Radio target link"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3666 'org-linked-text t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3667 t)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3668
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3669 (defun org-update-radio-target-regexp ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3670 "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
3671 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3672 (when (memq 'radio org-activate-links)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3673 (setq org-target-link-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3674 (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
3675 (org-restart-font-lock)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3676
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3677 (defun org-hide-wide-columns (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3678 (let (s e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3679 (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
3680 'org-cwidth t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3681 (when s
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3682 (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
3683 (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
3684 (goto-char e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3685 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3686
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3687 (defvar org-latex-and-specials-regexp nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3688 "Regular expression for highlighting export special stuff.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3689 (defvar org-match-substring-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3690 (defvar org-match-substring-with-braces-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3691 (defvar org-export-html-special-string-regexps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3692
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3693 (defun org-compute-latex-and-specials-regexp ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3694 "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
3695 (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
3696 (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
3697 (require 'org-exp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3698 (let*
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3699 ((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
3700 (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
3701 org-latex-regexps)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3702 (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
3703 (org-infile-export-plist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3704 (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
3705 (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
3706 (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
3707 (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
3708 (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
3709 (re-sub
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3710 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3711 ((equal org-export-with-sub-superscripts '{})
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3712 (list org-match-substring-with-braces-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3713 (org-export-with-sub-superscripts
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3714 (list org-match-substring-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3715 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3716 (re-latex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3717 (if org-export-with-LaTeX-fragments
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3718 (mapcar (lambda (x) (nth 1 x)) latexs)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3719 (re-macros
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3720 (if org-export-with-TeX-macros
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3721 (list (concat "\\\\"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3722 (regexp-opt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3723 (append (mapcar 'car org-html-entities)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3724 (if (boundp 'org-latex-entities)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3725 org-latex-entities nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3726 'words))) ; FIXME
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 ;; (list "\\\\\\(?:[a-zA-Z]+\\)")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3729 (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
3730 (mapcar (lambda (x) (car x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3731 org-export-html-special-string-regexps)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3732 (re-rest
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3733 (delq nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3734 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3735 (if org-export-html-expand "@<[^>\n]+>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3736 ))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3737 (org-set-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3738 'org-latex-and-specials-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3739 (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
3740 re-rest) "\\|")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3741
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3742 (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
3743 "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
3744 (when org-latex-and-specials-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3745 (let (rtn d)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3746 (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
3747 limit t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3748 (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
3749 'face))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3750 '(org-code org-verbatim underline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3751 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3752 (setq rtn t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3753 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
3754 '(?_ ?^)) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3755 (t 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3756 (font-lock-prepend-text-property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3757 (+ d (match-beginning 0)) (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3758 'face 'org-latex-and-export-specials)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3759 (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
3760 '(font-lock-multiline t)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3761 rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3762
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3763 (defun org-restart-font-lock ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3764 "Restart font-lock-mode, to force refontification."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3765 (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
3766 (font-lock-mode -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3767 (font-lock-mode 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3768
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3769 (defun org-all-targets (&optional radio)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3770 "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
3771 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
3772 (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
3773 rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3774 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3775 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3776 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3777 (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
3778 rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3779
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3780 (defun org-make-target-link-regexp (targets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3781 "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
3782 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
3783 between words."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3784 (and targets
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3785 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3786 "\\<\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3787 (mapconcat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3788 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3789 (while (string-match " +" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3790 (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
3791 x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3792 targets
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3793 "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3794 "\\)\\>")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3795
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3796 (defun org-activate-tags (limit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3797 (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
3798 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3799 (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
3800 (list 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3801 'rear-nonsticky org-nonsticky-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3802 'keymap org-mouse-map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3803 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3804
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3805 (defun org-outline-level ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3806 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3807 (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3808 (if (match-beginning 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3809 (+ (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
3810 (1- (- (match-end 0) (match-beginning 0))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3811
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3812 (defvar org-font-lock-keywords nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3813
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3814 (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
3815 "Regular expression matching a property line.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3816
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3817 (defvar org-font-lock-hook nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3818 "Functions to be called for special font lock stuff.")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3819
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3820 (defun org-font-lock-hook (limit)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3821 (run-hook-with-args 'org-font-lock-hook limit))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3822
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3823 (defun org-set-font-lock-defaults ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3824 (let* ((em org-fontify-emphasized-text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3825 (lk org-activate-links)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3826 (org-font-lock-extra-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3827 (list
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3828 ;; Call the hook
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3829 '(org-font-lock-hook)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3830 ;; Headlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3831 '("^\\(\\**\\)\\(\\* \\)\\(.*\\)" (1 (org-get-level-face 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3832 (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
3833 ;; Table lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3834 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3835 (1 'org-table t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3836 ;; Table internals
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3837 '("^[ \t]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3838 '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3839 '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3840 ;; Drawers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3841 (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
3842 (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
3843 ;; Properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3844 (list org-property-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3845 '(1 'org-special-keyword t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3846 '(3 'org-property-value t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3847 (if org-format-transports-properties-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3848 '("| *\\(<[0-9]+>\\) *" (1 'org-formula t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3849 ;; Links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3850 (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
3851 (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
3852 (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
3853 (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
3854 (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
3855 (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
3856 '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3857 '(org-hide-wide-columns (0 nil append))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3858 ;; TODO lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3859 (list (concat "^\\*+[ \t]+" org-todo-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3860 '(1 (org-get-todo-face 1) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3861 ;; DONE
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3862 (if org-fontify-done-headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3863 (list (concat "^[*]+ +\\<\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3864 (mapconcat 'regexp-quote org-done-keywords "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3865 "\\)\\(.*\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3866 '(2 'org-headline-done t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3867 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3868 ;; Priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3869 (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
3870 ;; Special keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3871 (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
3872 (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
3873 (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
3874 (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
3875 ;; Emphasis
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3876 (if em
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3877 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3878 '(org-do-emphasis-faces (0 nil append))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3879 '(org-do-emphasis-faces)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3880 ;; Checkboxes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3881 '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3882 2 'bold prepend)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3883 (if org-provide-checkbox-statistics
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3884 '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3885 (0 (org-get-checkbox-statistics-face) t)))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3886 ;; Description list items
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3887 '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(.*? ::\\)"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3888 2 'bold prepend)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3889 (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3890 '(1 'org-archived prepend))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3891 ;; Specials
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3892 '(org-do-latex-and-special-faces)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3893 ;; Code
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3894 '(org-activate-code (1 'org-code t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3895 ;; COMMENT
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3896 (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3897 "\\|" org-quote-string "\\)\\>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3898 '(1 'org-special-keyword t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3899 '("^#.*" (0 'font-lock-comment-face t))
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 (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
3902 ;; Now set the full font-lock-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3903 (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
3904 (org-set-local 'font-lock-defaults
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3905 '(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
3906 (kill-local-variable 'font-lock-keywords) nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3907
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3908 (defvar org-m nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3909 (defvar org-l nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3910 (defvar org-f nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3911 (defun org-get-level-face (n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3912 "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
3913 (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
3914 (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
3915 (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
3916 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3917 ((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
3918 ((eq n 2) org-f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3919 (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
3920
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3921 (defun org-get-todo-face (kwd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3922 "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
3923 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
3924 (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
3925 (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
3926 (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
3927 'org-todo))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3928
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3929 (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
3930 "Remove fontification and activation overlays from links."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3931 (font-lock-default-unfontify-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3932 (let* ((buffer-undo-list t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3933 (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
3934 (inhibit-modification-hooks t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3935 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
3936 (remove-text-properties beg end
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3937 '(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
3938 invisible t intangible t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3939
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3940 ;;;; 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
3941
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3942 ;;; Cycling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3943
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3944 (defvar org-cycle-global-status nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3945 (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
3946 (defvar org-cycle-subtree-status nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3947 (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
3948
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3949 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3950 (defun org-cycle (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3951 "Visibility cycling for Org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3952
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3953 - 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
3954 buffer through 3 states (global cycling)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3955 1. OVERVIEW: Show only top-level headlines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3956 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
3957 3. SHOW ALL: Show everything.
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
3958 When called with two C-u C-u prefixes, switch to the startup visibility,
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3959 determined by the variable `org-startup-folded', and by any VISIBILITY
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3960 properties in the buffer.
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
3961 When called with three C-u C-u C-u prefixed, show the entire buffer,
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
3962 including drawers.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3963
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3964 - 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
3965 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
3966 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
3967 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
3968 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
3969 and zoom in further.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3970 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
3971
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3972 - 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
3973 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
3974 is negative, go up that many levels.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3975
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3976 - When point is not at the beginning of a headline, execute the global
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
3977 binding for TAB, which is re-indenting the line. See the option
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3978 `org-cycle-emulate-tab' for details.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3979
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3980 - 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
3981 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
3982 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
3983 (interactive "P")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
3984 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3985 (let* ((outline-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3986 (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
3987 "\\(?:\\*+ \\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) \\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3988 outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3989 (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
3990 (not (looking-at outline-regexp))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3991 (org-cycle-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3992 (if bob-special
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3993 (delq 'org-optimize-window-after-visibility-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3994 (copy-sequence org-cycle-hook))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3995 org-cycle-hook))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3996 (pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3997
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3998 (if (or bob-special (equal arg '(4)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3999 ;; special case: use global cycling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4000 (setq arg t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4001
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4002 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4003
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4004 ((equal arg '(16))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4005 (org-set-startup-visibility)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4006 (message "Startup visibility, plus VISIBILITY properties"))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4007
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4008 ((equal arg '(64))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4009 (show-all)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4010 (message "Entire buffer visible, including drawers"))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4011
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4012 ((org-at-table-p 'any)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4013 ;; 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
4014 (or (org-table-recognize-table.el)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4015 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4016 (if arg (org-table-edit-field t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4017 (org-table-justify-field-maybe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4018 (call-interactively 'org-table-next-field)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4019
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4020 ((eq arg t) ;; Global cycling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4021
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4022 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4023 ((and (eq last-command this-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4024 (eq org-cycle-global-status 'overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4025 ;; 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
4026 ;; 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
4027 (message "CONTENTS...")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4028 (org-content)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4029 (message "CONTENTS...done")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4030 (setq org-cycle-global-status 'contents)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4031 (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
4032
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4033 ((and (eq last-command this-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4034 (eq org-cycle-global-status 'contents))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4035 ;; 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
4036 (show-all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4037 (message "SHOW ALL")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4038 (setq org-cycle-global-status 'all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4039 (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
4040
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4041 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4042 ;; Default action: go to overview
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4043 (org-overview)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4044 (message "OVERVIEW")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4045 (setq org-cycle-global-status 'overview)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4046 (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
4047
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4048 ((and org-drawers org-drawer-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4049 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4050 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4051 (looking-at org-drawer-regexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4052 ;; Toggle block visibility
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4053 (org-flag-drawer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4054 (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
4055
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4056 ((integerp arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4057 ;; Show-subtree, ARG levels up from here.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4058 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4059 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4060 (outline-up-heading (if (< arg 0) (- arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4061 (- (funcall outline-level) arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4062 (org-show-subtree)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4063
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4064 ((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
4065 (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
4066 ;; 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
4067 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4068 (let ((goal-column 0) eoh eol eos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4069 ;; First, some boundaries
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4070 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4071 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4072 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4073 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4074 (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
4075 (get-char-property (1- (point)) 'invisible))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4076 (beginning-of-line 2)) (setq eol (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4077 (outline-end-of-heading) (setq eoh (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4078 (org-end-of-subtree t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4079 (unless (eobp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4080 (skip-chars-forward " \t\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4081 (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
4082 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4083 (setq eos (1- (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4084 ;; 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
4085 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4086 ((= eos eoh)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4087 ;; Nothing is hidden behind this heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4088 (message "EMPTY ENTRY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4089 (setq org-cycle-subtree-status nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4090 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4091 (goto-char eos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4092 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4093 (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
4094 ((or (>= eol eos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4095 (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
4096 ;; 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
4097 (org-show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4098 (show-children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4099 (message "CHILDREN")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4100 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4101 (goto-char eos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4102 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4103 (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
4104 (setq org-cycle-subtree-status 'children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4105 (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
4106 ((and (eq last-command this-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4107 (eq org-cycle-subtree-status 'children))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4108 ;; 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
4109 (org-show-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4110 (message "SUBTREE")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4111 (setq org-cycle-subtree-status 'subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4112 (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
4113 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4114 ;; Default action: hide the subtree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4115 (hide-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4116 (message "FOLDED")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4117 (setq org-cycle-subtree-status 'folded)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4118 (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
4119
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4120 ;; TAB emulation and template completion
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4121 (buffer-read-only (org-back-to-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4122
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4123 ((org-try-structure-completion))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4124
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4125 ((org-try-cdlatex-tab))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4126
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4127 ((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
4128 (or (not (bolp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4129 (not (looking-at outline-regexp))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4130 (call-interactively (global-key-binding "\t")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4131
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4132 ((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
4133 (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
4134 (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
4135 (= (match-end 0) (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4136 (and (eq org-cycle-emulate-tab 'whitestart)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4137 (>= (match-end 0) pos))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4138 t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4139 (eq org-cycle-emulate-tab t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4140 (call-interactively (global-key-binding "\t")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4142 (t (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4143 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4144 (org-cycle))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4145
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4146 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4147 (defun org-global-cycle (&optional arg)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4148 "Cycle the global visibility. For details see `org-cycle'.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4149 With C-u prefix arg, switch to startup visibility.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4150 With a numeric prefix, show all headlines up to that level."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4151 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4152 (let ((org-cycle-include-plain-lists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4153 (if (org-mode-p) org-cycle-include-plain-lists nil)))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4154 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4155 ((integerp arg)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4156 (show-all)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4157 (hide-sublevels arg)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4158 (setq org-cycle-global-status 'contents))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4159 ((equal arg '(4))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4160 (org-set-startup-visibility)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4161 (message "Startup visibility, plus VISIBILITY properties."))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4162 (t
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4163 (org-cycle '(4))))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4164
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4165 (defun org-set-startup-visibility ()
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4166 "Set the visibility required by startup options and properties."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4167 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4168 ((eq org-startup-folded t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4169 (org-cycle '(4)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4170 ((eq org-startup-folded 'content)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4171 (let ((this-command 'org-cycle) (last-command 'org-cycle))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4172 (org-cycle '(4)) (org-cycle '(4)))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4173 (org-set-visibility-according-to-property 'no-cleanup)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4174 (org-cycle-hide-archived-subtrees 'all)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4175 (org-cycle-hide-drawers 'all)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4176 (org-cycle-show-empty-lines 'all))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4177
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4178 (defun org-set-visibility-according-to-property (&optional no-cleanup)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4179 "Switch subtree visibilities according to :VISIBILITY: property."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4180 (interactive)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4181 (let (state)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4182 (save-excursion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4183 (goto-char (point-min))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4184 (while (re-search-forward
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4185 "^[ \t]*:VISIBILITY:[ \t]+\\([a-z]+\\)"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4186 nil t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4187 (setq state (match-string 1))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4188 (save-excursion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4189 (org-back-to-heading t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4190 (hide-subtree)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4191 (org-reveal)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4192 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4193 ((equal state '("fold" "folded"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4194 (hide-subtree))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4195 ((equal state "children")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4196 (org-show-hidden-entry)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4197 (show-children))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4198 ((equal state "content")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4199 (save-excursion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4200 (save-restriction
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4201 (org-narrow-to-subtree)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4202 (org-content))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4203 ((member state '("all" "showall"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4204 (show-subtree)))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4205 (unless no-cleanup
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4206 (org-cycle-hide-archived-subtrees 'all)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4207 (org-cycle-hide-drawers 'all)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4208 (org-cycle-show-empty-lines 'all)))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4209
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4210 (defun org-overview ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4211 "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
4212 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
4213 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
4214 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
4215 results."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4216 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4217 (let ((level (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4218 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4219 (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
4220 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4221 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4222 (funcall outline-level))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4223 (and level (hide-sublevels level))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4224
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4225 (defun org-content (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4226 "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
4227 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
4228 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4229 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4230 ;; Visit all headings and show their offspring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4231 (and (integerp arg) (org-overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4232 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4233 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4234 (while (and (progn (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4235 (outline-previous-visible-heading 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4236 (error (goto-char (point-min))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4237 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4238 (looking-at outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4239 (if (integerp arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4240 (show-children (1- arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4241 (show-branches))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4242 (if (bobp) (throw 'exit nil))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4243
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4244
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4245 (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
4246 "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
4247 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
4248 (when (get-buffer-window (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4249 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4250 ; ((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
4251 ; ((eq state 'overview) (org-beginning-of-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4252 ((eq state 'content) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4253 ((eq state 'all) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4254 ((eq state 'folded) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4255 ((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
4256 ((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
4257
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4258 (defun org-compact-display-after-subtree-move ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4259 (let (beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4260 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4261 (if (org-up-heading-safe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4262 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4263 (hide-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4264 (show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4265 (show-children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4266 (org-cycle-show-empty-lines 'children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4267 (org-cycle-hide-drawers 'children))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4268 (org-overview)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4269
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4270 (defun org-cycle-show-empty-lines (state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4271 "Show empty lines above all visible headlines.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4272 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
4273 `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
4274 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
4275 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
4276 (when (> org-cycle-separator-lines 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4277 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4278 (let* ((n org-cycle-separator-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4279 (re (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4280 ((= n 1) "\\(\n[ \t]*\n\\*+\\) ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4281 ((= n 2) "^[ \t]*\\(\n[ \t]*\n\\*+\\) ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4282 (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
4283 (concat "^\\(?:[ \t]*\n\\)\\{" ns "," ns "\\}"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4284 "[ \t]*\\(\n[ \t]*\n\\*+\\) ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4285 beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4286 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4287 ((memq state '(overview contents t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4288 (setq beg (point-min) end (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4289 ((memq state '(children folded))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4290 (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
4291 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4292 (point)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4293 (when beg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4294 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4295 (while (re-search-forward re end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4296 (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
4297 (outline-flag-region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4298 (match-beginning 1) (match-end 1) nil)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4299 ;; 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
4300 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4301 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4302 (outline-previous-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4303 (outline-end-of-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4304 (if (and (looking-at "[ \t\n]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4305 (= (match-end 0) (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4306 (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
4307
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
4308 (defun org-show-empty-lines-in-parent ()
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
4309 "Move to the parent and re-show empty lines before visible headlines."
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
4310 (save-excursion
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
4311 (let ((context (if (org-up-heading-safe) 'children 'overview)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
4312 (org-cycle-show-empty-lines context))))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
4313
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4314 (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
4315 "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
4316 (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
4317 (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
4318 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4319 (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
4320 (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
4321 (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
4322 (goto-char beg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4323 (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
4324 (org-flag-drawer t))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4325
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4326 (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
4327 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4328 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4329 (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
4330 (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
4331 (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
4332 (if (re-search-forward
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4333 "^[ \t]*:END:"
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4334 (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
4335 (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
4336 (error ":END: line missing"))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4337
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4338 (defun org-subtree-end-visible-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4339 "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
4340 (pos-visible-in-window-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4341 (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
4342
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4343 (defun org-first-headline-recenter (&optional N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4344 "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
4345 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
4346 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4347 (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
4348 (beginning-of-line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4349 (recenter (prefix-numeric-value N))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4350
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4351 ;;; Org-goto
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4352
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4353 (defvar org-goto-window-configuration nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4354 (defvar org-goto-marker nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4355 (defvar org-goto-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4356 (let ((map (make-sparse-keymap)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4357 (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
4358 (while (setq cmd (pop cmds))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4359 (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
4360 (suppress-keymap map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4361 (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
4362 (org-defkey map [(return)] 'org-goto-ret)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4363 (org-defkey map [(left)] 'org-goto-left)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4364 (org-defkey map [(right)] 'org-goto-right)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4365 (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
4366 (org-defkey map "\C-i" 'org-cycle)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4367 (org-defkey map [(tab)] 'org-cycle)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4368 (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
4369 (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
4370 (if org-goto-auto-isearch
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4371 (if (fboundp 'define-key-after)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4372 (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
4373 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4374 (org-defkey map "q" 'org-goto-quit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4375 (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
4376 (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
4377 (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
4378 (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
4379 (org-defkey map "u" 'outline-up-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4380 (org-defkey map "/" 'org-occur)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4381 (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
4382 (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
4383 (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
4384 (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
4385 (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
4386 map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4387
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4388 (defconst org-goto-help
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4389 "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
4390 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
4391 \[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
4392
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4393 (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
4394
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4395 ;; FIXME: Docstring doe not mention both interfaces
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4396 (defun org-goto (&optional alternative-interface)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4397 "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
4398
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4399 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
4400 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
4401 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
4402 which may not be what you want.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4403
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4404 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
4405 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
4406 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
4407 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
4408 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
4409 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
4410 the headline hierarchy above."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4411 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4412 (let* ((org-refile-targets '((nil . (:maxlevel . 10))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4413 (org-refile-use-outline-path t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4414 (interface
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4415 (if (not alternative-interface)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4416 org-goto-interface
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4417 (if (eq org-goto-interface 'outline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4418 'outline-path-completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4419 'outline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4420 (org-goto-start-pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4421 (selected-point
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4422 (if (eq interface 'outline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4423 (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
4424 (nth 3 (org-refile-get-location "Goto: ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4425 (if selected-point
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4426 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4427 (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
4428 (goto-char selected-point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4429 (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
4430 (org-show-context 'org-goto)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4431 (message "Quit"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4432
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4433 (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
4434 (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
4435 (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
4436
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4437 (defun org-get-location (buf help)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4438 "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
4439 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
4440 or nil."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4441 (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
4442 (isearch-hide-immediately nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4443 (isearch-search-fun-function
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4444 (lambda () 'org-goto-local-search-headings))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4445 (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
4446 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4447 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4448 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4449 (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
4450 (switch-to-buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4451 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4452 (make-indirect-buffer (current-buffer) "*org-goto*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4453 (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
4454 (with-output-to-temp-buffer "*Help*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4455 (princ help))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4456 (org-fit-window-to-buffer (get-buffer-window "*Help*"))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4457 (setq buffer-read-only nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4458 (let ((org-startup-truncated t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4459 (org-startup-folded nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4460 (org-startup-align-all-tables nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4461 (org-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4462 (org-overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4463 (setq buffer-read-only t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4464 (if (and (boundp 'org-goto-start-pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4465 (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
4466 (let ((org-show-hierarchy-above t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4467 (org-show-siblings t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4468 (org-show-following-heading t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4469 (goto-char org-goto-start-pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4470 (and (org-invisible-p) (org-show-context)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4471 (goto-char (point-min)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4472 (org-beginning-of-line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4473 (message "Select location and press RET")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4474 (use-local-map org-goto-map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4475 (recursive-edit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4476 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4477 (kill-buffer "*org-goto*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4478 (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
4479
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4480 (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
4481 (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
4482 (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
4483 (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
4484
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4485 (defun org-goto-local-search-headings (string bound noerror)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4486 "Search and make sure that any matches are in headlines."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4487 (catch 'return
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4488 (while (if isearch-forward
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4489 (search-forward string bound noerror)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4490 (search-backward string bound noerror))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4491 (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
4492 (and (member :headline context)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4493 (not (member :tags context))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4494 (throw 'return (point))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4495
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4496 (defun org-goto-local-auto-isearch ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4497 "Start isearch."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4498 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4499 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4500 (let ((keys (this-command-keys)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4501 (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
4502 (isearch-mode t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4503 (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
4504
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4505 (defun org-goto-ret (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4506 "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
4507 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4508 (setq org-goto-selected-point (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4509 org-goto-exit-command 'return)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4510 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4511
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4512 (defun org-goto-left ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4513 "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
4514 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4515 (if (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4516 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4517 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4518 (setq org-goto-selected-point (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4519 org-goto-exit-command 'left)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4520 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4521 (error "Not on a heading")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4522
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4523 (defun org-goto-right ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4524 "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
4525 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4526 (if (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4527 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4528 (setq org-goto-selected-point (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4529 org-goto-exit-command 'right)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4530 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4531 (error "Not on a heading")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4532
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4533 (defun org-goto-quit ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4534 "Finish `org-goto' without cursor motion."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4535 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4536 (setq org-goto-selected-point nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4537 (setq org-goto-exit-command 'quit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4538 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4539
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4540 ;;; Indirect buffer display of subtrees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4541
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4542 (defvar org-indirect-dedicated-frame nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4543 "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
4544 (defvar org-last-indirect-buffer nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4545
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4546 (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
4547 "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
4548 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
4549 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
4550 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
4551 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
4552 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
4553 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
4554 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
4555 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
4556 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
4557 frame is not changed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4558 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4559 (let ((cbuf (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4560 (cwin (selected-window))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4561 (pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4562 beg end level heading ibuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4563 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4564 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4565 (when (numberp arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4566 (setq level (org-outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4567 (if (< arg 0) (setq arg (+ level arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4568 (while (> (setq level (org-outline-level)) arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4569 (outline-up-heading 1 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4570 (setq beg (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4571 heading (org-get-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4572 (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
4573 (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
4574 (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
4575 (not arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4576 (kill-buffer org-last-indirect-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4577 (setq ibuf (org-get-indirect-buffer cbuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4578 org-last-indirect-buffer ibuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4579 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4580 ((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
4581 (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
4582 (select-frame (make-frame))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4583 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4584 (switch-to-buffer ibuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4585 (org-set-frame-title heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4586 ((eq org-indirect-buffer-display 'dedicated-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4587 (raise-frame
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4588 (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
4589 (frame-live-p org-indirect-dedicated-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4590 org-indirect-dedicated-frame)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4591 (setq org-indirect-dedicated-frame (make-frame)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4592 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4593 (switch-to-buffer ibuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4594 (org-set-frame-title (concat "Indirect: " heading)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4595 ((eq org-indirect-buffer-display 'current-window)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4596 (switch-to-buffer ibuf))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4597 ((eq org-indirect-buffer-display 'other-window)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4598 (pop-to-buffer ibuf))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4599 (t (error "Invalid value.")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4600 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4601 (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
4602 (narrow-to-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4603 (show-all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4604 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4605 (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
4606
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4607 (defun org-get-indirect-buffer (&optional buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4608 (setq buffer (or buffer (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4609 (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
4610 (while (buffer-live-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4611 (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
4612 (setq n (1+ n)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4613 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4614 (make-indirect-buffer buffer bname 'clone)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4615 (error (make-indirect-buffer buffer bname)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4616
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4617 (defun org-set-frame-title (title)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4618 "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
4619 ;; 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
4620 (unless (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4621 (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
4622
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4623 ;;;; Structure editing
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4624
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4625 ;;; Inserting headlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4626
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4627 (defun org-insert-heading (&optional force-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4628 "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
4629 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
4630 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
4631 current headline. If point is not at the beginning, do not split the line,
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4632 but create the new headline after the current line."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4633 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4634 (if (= (buffer-size) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4635 (insert "\n* ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4636 (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
4637 (let* ((head (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4638 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4639 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4640 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4641 (match-string 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4642 (error "*"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4643 (blank (cdr (assq 'heading org-blank-before-new-entry)))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4644 pos hide-previous previous-pos)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4645 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4646 ((and (org-on-heading-p) (bolp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4647 (or (bobp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4648 (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
4649 ;; insert before the current line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4650 (open-line (if blank 2 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4651 ((and (bolp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4652 (or (bobp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4653 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4654 (backward-char 1) (not (org-invisible-p)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4655 ;; insert right here
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4656 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4657 (t
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4658 ;; somewhere in the line
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4659 (save-excursion
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4660 (setq previous-pos (point-at-bol))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4661 (end-of-line)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4662 (setq hide-previous (org-invisible-p)))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4663 (and org-insert-heading-respect-content (org-show-subtree))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4664 (let ((split
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4665 (and (org-get-alist-option org-M-RET-may-split-line 'headline)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4666 (save-excursion
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4667 (let ((p (point)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4668 (goto-char (point-at-bol))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4669 (and (looking-at org-complex-heading-regexp)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4670 (> p (match-beginning 4)))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4671 tags pos)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4672 (cond
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4673 (org-insert-heading-respect-content
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4674 (org-end-of-subtree nil t)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4675 (or (bolp) (newline))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4676 (open-line 1))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4677 ((org-on-heading-p)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4678 (when hide-previous
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4679 (show-children)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4680 (org-show-entry))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4681 (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4682 (setq tags (and (match-end 2) (match-string 2)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4683 (and (match-end 1)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4684 (delete-region (match-beginning 1) (match-end 1)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4685 (setq pos (point-at-bol))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4686 (or split (end-of-line 1))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4687 (delete-horizontal-space)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4688 (newline (if blank 2 1))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4689 (when tags
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4690 (save-excursion
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4691 (goto-char pos)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4692 (end-of-line 1)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4693 (insert " " tags)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4694 (org-set-tags nil 'align))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4695 (t
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4696 (or split (end-of-line 1))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4697 (newline (if blank 2 1)))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4698 (insert head) (just-one-space)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4699 (setq pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4700 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4701 (unless (= (point) pos) (just-one-space) (backward-delete-char 1))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4702 (when (and org-insert-heading-respect-content hide-previous)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4703 (save-excursion
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4704 (goto-char previous-pos)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
4705 (hide-subtree)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4706 (run-hooks 'org-insert-heading-hook)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4707
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4708 (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
4709 "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
4710 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4711 (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
4712 (if (looking-at
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4713 (if no-tags
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4714 (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
4715 "\\*+[ \t]+\\([^\r\n]*\\)"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4716 (match-string 1) "")))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4717
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4718 (defun org-insert-heading-after-current ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4719 "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
4720 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4721 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4722 (org-insert-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4723 (org-move-subtree-down)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4724 (end-of-line 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4725
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4726 (defun org-insert-heading-respect-content ()
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4727 (interactive)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4728 (let ((org-insert-heading-respect-content t))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4729 (org-insert-heading t)))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4730
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4731 (defun org-insert-todo-heading-respect-content (&optional force-state)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4732 (interactive "P")
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
4733 (let ((org-insert-heading-respect-content t))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4734 (org-insert-todo-heading force-state t)))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4735
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4736 (defun org-insert-todo-heading (arg &optional force-heading)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4737 "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
4738 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
4739 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
4740 (interactive "P")
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4741 (when (or force-heading (not (org-insert-item 'checkbox)))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
4742 (org-insert-heading force-heading)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4743 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4744 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4745 (outline-previous-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4746 (looking-at org-todo-line-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4747 (if (or arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4748 (not (match-beginning 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4749 (member (match-string 2) org-done-keywords))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4750 (insert (car org-todo-keywords-1) " ")
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4751 (insert (match-string 2) " "))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4752 (when org-provide-todo-statistics
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
4753 (org-update-parent-todo-statistics))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4754
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4755 (defun org-insert-subheading (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4756 "Insert a new subheading and demote it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4757 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
4758 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4759 (org-insert-heading arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4760 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4761 ((org-on-heading-p) (org-do-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4762 ((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
4763
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4764 (defun org-insert-todo-subheading (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4765 "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
4766 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
4767 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4768 (org-insert-todo-heading arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4769 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4770 ((org-on-heading-p) (org-do-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4771 ((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
4772
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4773 ;;; Promotion and Demotion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4774
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4775 (defun org-promote-subtree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4776 "Promote the entire subtree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4777 See also `org-promote'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4778 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4779 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4780 (org-map-tree 'org-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4781 (org-fix-position-after-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4782
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4783 (defun org-demote-subtree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4784 "Demote the entire subtree. See `org-demote'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4785 See also `org-promote'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4786 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4787 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4788 (org-map-tree 'org-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4789 (org-fix-position-after-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4790
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4791
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4792 (defun org-do-promote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4793 "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
4794 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
4795 in the region."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4796 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4797 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4798 (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4799 (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
4800 (org-promote)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4801 (org-fix-position-after-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4802
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4803 (defun org-do-demote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4804 "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
4805 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
4806 in the region."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4807 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4808 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4809 (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4810 (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
4811 (org-demote)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4812 (org-fix-position-after-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4813
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4814 (defun org-fix-position-after-promote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4815 "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
4816 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4817 (when (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4818 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4819 (looking-at org-todo-line-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4820 (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
4821 (cond ((eobp) (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4822 ((eolp) (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4823 ((equal (char-after) ?\ ) (forward-char 1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4824
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4825 (defun org-reduced-level (l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4826 (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
4827
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4828 (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
4829 "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
4830 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
4831 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
4832 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
4833 (if org-odd-levels-only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4834 (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
4835 ((> 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
4836 ((< 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
4837 (max 1 (+ level change))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4838
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4839 (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
4840 (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
4841 (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
4842 'org-get-valid-level)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
4843 (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
4844 'org-get-valid-level "23.1")))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4845
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4846 (defun org-promote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4847 "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
4848 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
4849 in the region."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4850 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4851 (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
4852 (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
4853 (diff (abs (- level (length up-head) -1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4854 (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
4855 (replace-match up-head nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4856 ;; Fixup tag positioning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4857 (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
4858 (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
4859
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4860 (defun org-demote ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4861 "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
4862 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
4863 in the region."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4864 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4865 (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
4866 (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
4867 (diff (abs (- level (length down-head) -1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4868 (replace-match down-head nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4869 ;; Fixup tag positioning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4870 (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
4871 (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
4872
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4873 (defun org-map-tree (fun)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4874 "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
4875 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4876 (let ((level (funcall outline-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4877 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4878 (funcall fun)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4879 (while (and (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4880 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4881 (> (funcall outline-level) level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4882 (not (eobp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4883 (funcall fun)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4884
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4885 (defun org-map-region (fun beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4886 "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
4887 (let ((org-ignore-region t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4888 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4889 (setq end (copy-marker end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4890 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4891 (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
4892 (< (point) end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4893 (funcall fun))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4894 (while (and (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4895 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4896 (< (point) end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4897 (not (eobp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4898 (funcall fun)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4899
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4900 (defun org-fixup-indentation (diff)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4901 "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
4902 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
4903 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
4904 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4905 (let ((end (save-excursion (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4906 (point-marker)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4907 (prohibit (if (> diff 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4908 "^\\S-"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4909 (concat "^ \\{0," (int-to-string (- diff)) "\\}\\S-")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4910 col)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4911 (unless (save-excursion (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4912 (re-search-forward prohibit end t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4913 (while (and (< (point) end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4914 (re-search-forward "^[ \t]+" end t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4915 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4916 (setq col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4917 (if (< diff 0) (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4918 (indent-to (+ diff col))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4919 (move-marker end nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4920
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4921 (defun org-convert-to-odd-levels ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4922 "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
4923 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
4924 level 5 etc."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4925 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4926 (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
4927 (let ((org-odd-levels-only nil) n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4928 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4929 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4930 (while (re-search-forward "^\\*\\*+ " nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4931 (setq n (- (length (match-string 0)) 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4932 (while (>= (setq n (1- n)) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4933 (org-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4934 (end-of-line 1))))))
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
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4937 (defun org-convert-to-oddeven-levels ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4938 "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
4939 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
4940 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
4941 is signaled in this case."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4942 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4943 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4944 ;; 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
4945 (when (re-search-forward "^\\(\\*\\*\\)+ " nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4946 (org-show-context t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4947 (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
4948 (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
4949 (let ((org-odd-levels-only nil) n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4950 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4951 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4952 (while (re-search-forward "^\\*\\*+ " nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4953 (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
4954 (while (>= (setq n (1- n)) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4955 (org-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4956 (end-of-line 1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4957
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4958 (defun org-tr-level (n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4959 "Make N odd if required."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4960 (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
4961
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4962 ;;; 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
4963
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4964 (defun org-move-subtree-up (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4965 "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
4966 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4967 (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
4968
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4969 (defun org-move-subtree-down (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4970 "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
4971 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4972 (setq arg (prefix-numeric-value arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4973 (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
4974 'outline-get-last-sibling))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4975 (ins-point (make-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4976 (cnt (abs arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4977 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
4978 ;; Select the tree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4979 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4980 (setq beg0 (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4981 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4982 (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
4983 (setq beg (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4984 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4985 (save-excursion (outline-end-of-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4986 (setq folded (org-invisible-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4987 (outline-end-of-subtree))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4988 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4989 (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
4990 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4991 (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4992 (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
4993 ;; include less whitespace
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4994 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4995 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4996 (forward-line (- ne-beg ne-end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4997 (setq beg (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4998 ;; Find insertion point, with error handling
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4999 (while (> cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5000 (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
5001 (progn (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5002 (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
5003 (setq cnt (1- cnt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5004 (if (> arg 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5005 ;; 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
5006 (progn (org-end-of-subtree t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5007 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5008 (org-back-over-empty-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5009 (or (bolp) (newline)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5010 (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
5011 (move-marker ins-point (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5012 (setq txt (buffer-substring beg end))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5013 (org-save-markers-in-region beg end)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5014 (delete-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5015 (outline-flag-region (1- beg) beg nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5016 (outline-flag-region (1- (point)) (point) nil)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5017 (let ((bbb (point)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5018 (insert-before-markers txt)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5019 (org-reinstall-markers-in-region bbb)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5020 (move-marker ins-point bbb))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5021 (or (bolp) (insert "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5022 (setq ins-end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5023 (goto-char ins-point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5024 (org-skip-whitespace)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5025 (when (and (< arg 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5026 (org-first-sibling-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5027 (> ne-ins ne-beg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5028 ;; Move whitespace back to beginning
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5029 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5030 (goto-char ins-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5031 (let ((kill-whole-line t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5032 (kill-line (- ne-ins ne-beg)) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5033 (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
5034 (move-marker ins-point nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5035 (org-compact-display-after-subtree-move)
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
5036 (org-show-empty-lines-in-parent)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5037 (unless folded
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5038 (org-show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5039 (show-children)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5040 (org-cycle-hide-drawers 'children))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5041
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5042 (defvar org-subtree-clip ""
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5043 "Clipboard for cut and paste of subtrees.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5044 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
5045 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
5046
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5047 (defvar org-subtree-clip-folded nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5048 "Was the last copied subtree folded?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5049 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
5050
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5051 (defun org-cut-subtree (&optional n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5052 "Cut the current subtree into the clipboard.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5053 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
5054 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
5055 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5056 (org-copy-subtree n 'cut))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5057
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5058 (defun org-copy-subtree (&optional n cut force-store-markers)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5059 "Cut the current subtree into the clipboard.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5060 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
5061 This is a short-hand for marking the subtree and then copying it.
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5062 If CUT is non-nil, actually cut the subtree.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5063 If FORCE-STORE-MARKERS is non-nil, store the relative locations
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5064 of some markers in the region, even if CUT is non-nil. This is
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5065 useful if the caller implements cut-and-paste as copy-then-paste-then-cut."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5066 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5067 (let (beg end folded (beg0 (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5068 (if (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5069 (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
5070 (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
5071 (org-back-over-empty-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5072 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5073 (skip-chars-forward " \t\r\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5074 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5075 (save-excursion (outline-end-of-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5076 (setq folded (org-invisible-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5077 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5078 (outline-forward-same-level (1- n))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5079 (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5080 (org-end-of-subtree t t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5081 (org-back-over-empty-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5082 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5083 (goto-char beg0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5084 (when (> end beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5085 (setq org-subtree-clip-folded folded)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5086 (when (or cut force-store-markers)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5087 (org-save-markers-in-region beg end))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5088 (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
5089 (setq org-subtree-clip (current-kill 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5090 (message "%s: Subtree(s) with %d characters"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5091 (if cut "Cut" "Copied")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5092 (length org-subtree-clip)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5093
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5094 (defun org-paste-subtree (&optional level tree for-yank)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5095 "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
5096 The entire subtree is promoted or demoted in order to match a new headline
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5097 level.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5098
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5099 If the cursor is at the beginning of a headline, the same level as
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5100 that headline is used to paste the tree
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5101
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5102 If not, the new level is derived from the *visible* headings
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5103 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
5104 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
5105 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
5106 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
5107 not swallow low level entries.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5108
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5109 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
5110 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
5111 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
5112
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5113 If optional TREE is given, use this text instead of the kill ring.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5114
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5115 When FOR-YANK is set, this is called by `org-yank'. In this case, do not
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5116 move back over whitespace before inserting, and move point to the end of
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5117 the inserted text when done."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5118 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5119 (unless (org-kill-is-subtree-p tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5120 (error "%s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5121 (substitute-command-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5122 "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway")))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
5123 (let* ((visp (not (org-invisible-p)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
5124 (txt (or tree (and kill-ring (current-kill 0))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5125 (^re (concat "^\\(" outline-regexp "\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5126 (re (concat "\\(" outline-regexp "\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5127 (^re_ (concat "\\(\\*+\\)[ \t]*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5128
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5129 (old-level (if (string-match ^re txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5130 (- (match-end 0) (match-beginning 0) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5131 -1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5132 (force-level (cond (level (prefix-numeric-value level))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5133 ((and (looking-at "[ \t]*$")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5134 (string-match
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5135 ^re_ (buffer-substring
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5136 (point-at-bol) (point))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5137 (- (match-end 1) (match-beginning 1)))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5138 ((and (bolp)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5139 (looking-at org-outline-regexp))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5140 (- (match-end 0) (point) 1))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5141 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5142 (previous-level (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5143 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5144 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5145 (outline-previous-visible-heading 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5146 (if (looking-at re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5147 (- (match-end 0) (match-beginning 0) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5148 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5149 (error 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5150 (next-level (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5151 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5152 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5153 (or (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5154 (outline-next-visible-heading 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5155 (if (looking-at re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5156 (- (match-end 0) (match-beginning 0) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5157 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5158 (error 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5159 (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
5160 (shift (if (or (= old-level -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5161 (= new-level -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5162 (= old-level new-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5163 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5164 (- new-level old-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5165 (delta (if (> shift 0) -1 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5166 (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
5167 (org-odd-levels-only nil)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5168 beg end newend)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5169 ;; Remove the forced level indicator
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5170 (if force-level
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5171 (delete-region (point-at-bol) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5172 ;; Paste
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5173 (beginning-of-line 1)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5174 (unless for-yank (org-back-over-empty-lines))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5175 (setq beg (point))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5176 (insert-before-markers txt)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5177 (unless (string-match "\n\\'" txt) (insert "\n"))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5178 (setq newend (point))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5179 (org-reinstall-markers-in-region beg)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5180 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5181 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5182 (skip-chars-forward " \t\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5183 (setq beg (point))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
5184 (if (and (org-invisible-p) visp)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
5185 (save-excursion (outline-show-heading)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5186 ;; Shift if necessary
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5187 (unless (= shift 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5188 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5189 (narrow-to-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5190 (while (not (= shift 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5191 (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
5192 (setq shift (+ delta shift)))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5193 (goto-char (point-min))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5194 (setq newend (point-max))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5195 (when (or (interactive-p) for-yank)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5196 (message "Clipboard pasted as level %d subtree" new-level))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5197 (if (and (not for-yank) ; in this case, org-yank will decide about folding
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5198 kill-ring
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5199 (eq org-subtree-clip (current-kill 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5200 org-subtree-clip-folded)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5201 ;; The tree was folded before it was killed/copied
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5202 (hide-subtree))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5203 (and for-yank (goto-char newend))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5204
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5205 (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
5206 "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
5207 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
5208 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
5209 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
5210 which is OK for `org-paste-subtree'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5211 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
5212 (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
5213 (start-level (and kill
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5214 (string-match (concat "\\`\\([ \t\n\r]*?\n\\)?\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5215 org-outline-regexp "\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5216 kill)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5217 (- (match-end 2) (match-beginning 2) 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5218 (re (concat "^" org-outline-regexp))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5219 (start (1+ (or (match-beginning 2) -1))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5220 (if (not start-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5221 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5222 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
5223 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5224 (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
5225 (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
5226 (throw 'exit nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5227 t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5228
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5229 (defvar org-markers-to-move nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5230 "Markers that should be moved with a cut-and-paste operation.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5231 Those markers are stored together with their positions relative to
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5232 the start of the region.")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5233
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5234 (defun org-save-markers-in-region (beg end)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5235 "Check markers in region.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5236 If these markers are between BEG and END, record their position relative
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5237 to BEG, so that after moving the block of text, we can put the markers back
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5238 into place.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5239 This function gets called just before an entry or tree gets cut from the
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5240 buffer. After re-insertion, `org-reinstall-markers-in-region' must be
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5241 called immediately, to move the markers with the entries."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5242 (setq org-markers-to-move nil)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5243 (when (featurep 'org-clock)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5244 (org-clock-save-markers-for-cut-and-paste beg end))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5245 (when (featurep 'org-agenda)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5246 (org-agenda-save-markers-for-cut-and-paste beg end)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5247
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5248 (defun org-check-and-save-marker (marker beg end)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5249 "Check if MARKER is between BEG and END.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5250 If yes, remember the marker and the distance to BEG."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5251 (when (and (marker-buffer marker)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5252 (equal (marker-buffer marker) (current-buffer)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5253 (if (and (>= marker beg) (< marker end))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5254 (push (cons marker (- marker beg)) org-markers-to-move))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5255
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5256 (defun org-reinstall-markers-in-region (beg)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5257 "Move all remembered markers to their position relative to BEG."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5258 (mapc (lambda (x)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5259 (move-marker (car x) (+ beg (cdr x))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5260 org-markers-to-move)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5261 (setq org-markers-to-move nil))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5262
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5263 (defun org-narrow-to-subtree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5264 "Narrow buffer to the current subtree."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5265 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5266 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5267 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5268 (narrow-to-region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5269 (progn (org-back-to-heading) (point))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
5270 (progn (org-end-of-subtree t) (point))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5271
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 ;;; Outline Sorting
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5274
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5275 (defun org-sort (with-case)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5276 "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
5277 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
5278 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5279 (if (org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5280 (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
5281 (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
5282
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5283 (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
5284 (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
5285 (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
5286 (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
5287 (match-string 3 s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5288 (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
5289 s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5290
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5291 (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
5292
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5293 (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
5294 "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
5295 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
5296 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
5297 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
5298
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5299 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
5300 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
5301 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
5302 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
5303 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
5304 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
5305 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
5306
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5307 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
5308 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
5309 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5310 (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
5311 start beg end stars re re2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5312 txt what tmp plain-list-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5313 ;; 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
5314 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5315 ((org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5316 ;; we will sort the region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5317 (setq end (region-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5318 what "region")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5319 (goto-char (region-beginning))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5320 (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
5321 (setq start (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5322 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5323 ;; we will sort this plain list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5324 (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
5325 (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
5326 (goto-char start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5327 (setq plain-list-p t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5328 what "plain list"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5329 ((or (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5330 (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
5331 ;; 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
5332 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5333 (setq start (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5334 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
5335 (org-back-over-empty-lines)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5336 (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5337 what "children")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5338 (goto-char start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5339 (show-subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5340 (outline-next-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5341 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5342 ;; 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
5343 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5344 (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
5345 (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
5346 (goto-char start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5347 (show-all)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5348
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5349 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5350 (if (>= beg end) (error "Nothing to sort"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5351
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5352 (unless plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5353 (looking-at "\\(\\*+\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5354 (setq stars (match-string 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5355 re (concat "^" (regexp-quote stars) " +")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5356 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
5357 txt (buffer-substring beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5358 (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
5359 (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
5360 (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
5361
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5362 (unless sorting-type
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5363 (message
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5364 (if plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5365 "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
5366 "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
5367 what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5368 (setq sorting-type (read-char-exclusive))
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 (and (= (downcase sorting-type) ?f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5371 (setq getkey-func
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5372 (completing-read "Sort using function: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5373 obarray 'fboundp t nil nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5374 (setq getkey-func (intern getkey-func)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5375
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5376 (and (= (downcase sorting-type) ?r)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5377 (setq property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5378 (completing-read "Property: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5379 (mapcar 'list (org-buffer-property-keys t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5380 nil t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5381
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5382 (message "Sorting entries...")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5383
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5384 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5385 (narrow-to-region start end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5386
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5387 (let ((dcst (downcase sorting-type))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5388 (now (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5389 (sort-subr
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5390 (/= dcst sorting-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5391 ;; 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
5392 ;; be sorted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5393 (if plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5394 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5395 (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
5396 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5397 (if (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5398 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5399 (goto-char (point-max)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5400 ;; 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
5401 ;; sorted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5402 (if plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5403 'org-end-of-item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5404 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5405 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5406 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5407 (outline-forward-same-level 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5408 (error
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5409 (goto-char (point-max)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5410
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5411 ;; 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
5412 (if plain-list-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5413 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5414 (when (looking-at "[ \t]*[-+*0-9.)]+[ \t]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5415 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5416 ((= dcst ?n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5417 (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
5418 (point-at-eol))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5419 ((= dcst ?a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5420 (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
5421 ((= dcst ?t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5422 (if (re-search-forward org-ts-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5423 (point-at-eol) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5424 (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
5425 now))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5426 ((= dcst ?f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5427 (if getkey-func
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5428 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5429 (setq tmp (funcall getkey-func))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5430 (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
5431 tmp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5432 (error "Invalid key function `%s'" getkey-func)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5433 (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
5434 (lambda nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5435 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5436 ((= dcst ?n)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5437 (if (looking-at org-complex-heading-regexp)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5438 (string-to-number (match-string 4))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5439 nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5440 ((= dcst ?a)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5441 (if (looking-at org-complex-heading-regexp)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5442 (funcall case-func (match-string 4))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5443 nil))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5444 ((= dcst ?t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5445 (if (re-search-forward org-ts-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5446 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5447 (forward-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5448 (point)) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5449 (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
5450 now))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5451 ((= dcst ?p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5452 (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
5453 (string-to-char (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5454 org-default-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5455 ((= dcst ?r)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5456 (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
5457 ((= dcst ?o)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5458 (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
5459 (- 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
5460 org-todo-keywords-1)))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5461 ((= dcst ?f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5462 (if getkey-func
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5463 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5464 (setq tmp (funcall getkey-func))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5465 (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
5466 tmp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5467 (error "Invalid key function `%s'" getkey-func)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5468 (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
5469 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5470 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5471 ((= dcst ?a) 'string<)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5472 ((= dcst ?t) 'time-less-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5473 (t nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5474 (message "Sorting entries...done")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5475
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5476 (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
5477 "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
5478 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
5479 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
5480 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
5481 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
5482 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
5483 (unless sorting-type
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5484 (message
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5485 "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
5486 what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5487 (setq sorting-type (read-char-exclusive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5488 (let ((dcst (downcase sorting-type))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5489 extractfun comparefun)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5490 ;; Define the appropriate functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5491 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5492 ((= dcst ?n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5493 (setq extractfun 'string-to-number
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5494 comparefun (if (= dcst sorting-type) '< '>)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5495 ((= dcst ?a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5496 (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
5497 (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
5498 comparefun (if (= dcst sorting-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5499 'string<
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5500 (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
5501 (not (string= a b)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5502 ((= dcst ?t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5503 (setq extractfun
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5504 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5505 (if (string-match org-ts-regexp x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5506 (time-to-seconds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5507 (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
5508 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5509 comparefun (if (= dcst sorting-type) '< '>)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5510 (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
5511
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5512 (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
5513 table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5514 (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
5515
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5516 ;;; Editing source examples
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5517
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5518 (defvar org-exit-edit-mode-map (make-sparse-keymap))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5519 (define-key org-exit-edit-mode-map "\C-c'" 'org-edit-src-exit)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5520 (defvar org-edit-src-force-single-line nil)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5521 (defvar org-edit-src-from-org-mode nil)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5522 (defvar org-edit-src-picture nil)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5523
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5524 (define-minor-mode org-exit-edit-mode
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5525 "Minor mode installing a single key binding, \"C-c '\" to exit special edit.")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5526
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5527 (defun org-edit-src-code ()
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5528 "Edit the source code example at point.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5529 An indirect buffer is created, and that buffer is then narrowed to the
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5530 example at point and switched to the correct language mode. When done,
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5531 exit by killing the buffer with \\[org-edit-src-exit]."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5532 (interactive)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5533 (let ((line (org-current-line))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5534 (case-fold-search t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5535 (msg (substitute-command-keys
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5536 "Edit, then exit with C-c ' (C-c and single quote)"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5537 (info (org-edit-src-find-region-and-lang))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5538 (org-mode-p (eq major-mode 'org-mode))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5539 beg end lang lang-f single)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5540 (if (not info)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5541 nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5542 (setq beg (nth 0 info)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5543 end (nth 1 info)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5544 lang (nth 2 info)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5545 single (nth 3 info)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5546 lang-f (intern (concat lang "-mode")))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5547 (unless (functionp lang-f)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5548 (error "No such language mode: %s" lang-f))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5549 (goto-line line)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5550 (if (get-buffer "*Org Edit Src Example*")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5551 (kill-buffer "*Org Edit Src Example*"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5552 (switch-to-buffer (make-indirect-buffer (current-buffer)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5553 "*Org Edit Src Example*"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5554 (narrow-to-region beg end)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5555 (remove-text-properties beg end '(display nil invisible nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5556 intangible nil))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5557 (let ((org-inhibit-startup t))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5558 (funcall lang-f))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5559 (set (make-local-variable 'org-edit-src-force-single-line) single)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5560 (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5561 (when org-mode-p
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5562 (goto-char (point-min))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5563 (while (re-search-forward "^," nil t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5564 (replace-match "")))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5565 (goto-line line)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5566 (org-exit-edit-mode)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5567 (org-set-local 'header-line-format msg)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5568 (message "%s" msg)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5569 t)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5570
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5571 (defun org-edit-fixed-width-region ()
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5572 "Edit the fixed-width ascii drawing at point.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5573 This must be a region where each line starts with ca colon followed by
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5574 a space character.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5575 An indirect buffer is created, and that buffer is then narrowed to the
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5576 example at point and switched to artist-mode. When done,
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5577 exit by killing the buffer with \\[org-edit-src-exit]."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5578 (interactive)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5579 (let ((line (org-current-line))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5580 (case-fold-search t)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5581 (msg (substitute-command-keys
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5582 "Edit, then exit with C-c ' (C-c and single quote)"))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5583 (org-mode-p (eq major-mode 'org-mode))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5584 beg end lang lang-f)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5585 (beginning-of-line 1)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5586 (if (looking-at "[ \t]*[^:\n \t]")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5587 nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5588 (if (looking-at "[ \t]*\\(\n\\|\\'\\)]")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5589 (setq beg (point) end (match-end 0))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5590 (save-excursion
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5591 (if (re-search-backward "^[ \t]*[^:]" nil 'move)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5592 (setq beg (point-at-bol 2))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5593 (setq beg (point))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5594 (save-excursion
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5595 (if (re-search-forward "^[ \t]*[^:]" nil 'move)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5596 (setq end (1- (match-beginning 0)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5597 (setq end (point))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5598 (goto-line line)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5599 (if (get-buffer "*Org Edit Picture*")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5600 (kill-buffer "*Org Edit Picture*"))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5601 (switch-to-buffer (make-indirect-buffer (current-buffer)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5602 "*Org Edit Picture*"))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5603 (narrow-to-region beg end)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5604 (remove-text-properties beg end '(display nil invisible nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5605 intangible nil))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5606 (when (fboundp 'font-lock-unfontify-region)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5607 (font-lock-unfontify-region (point-min) (point-max)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5608 (cond
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5609 ((eq org-edit-fixed-width-region-mode 'artist-mode)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5610 (fundamental-mode)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5611 (artist-mode 1))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5612 (t (funcall org-edit-fixed-width-region-mode)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5613 (set (make-local-variable 'org-edit-src-force-single-line) nil)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5614 (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5615 (set (make-local-variable 'org-edit-src-picture) t)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5616 (goto-char (point-min))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5617 (while (re-search-forward "^[ \t]*: " nil t)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5618 (replace-match ""))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5619 (goto-line line)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5620 (org-exit-edit-mode)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5621 (org-set-local 'header-line-format msg)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5622 (message "%s" msg)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5623 t))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5624
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5625
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5626 (defun org-edit-src-find-region-and-lang ()
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5627 "Find the region and language for a local edit.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5628 Return a list with beginning and end of the region, a string representing
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5629 the language, a switch telling of the content should be in a single line."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5630 (let ((re-list
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5631 (append
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5632 org-edit-src-region-extra
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5633 '(
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5634 ("<src\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</src>" lang)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5635 ("<literal\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</literal>" style)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5636 ("<example>[ \t]*\n?" "\n?[ \t]*</example>" "fundamental")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5637 ("<lisp>[ \t]*\n?" "\n?[ \t]*</lisp>" "emacs-lisp")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5638 ("<perl>[ \t]*\n?" "\n?[ \t]*</perl>" "perl")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5639 ("<python>[ \t]*\n?" "\n?[ \t]*</python>" "python")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5640 ("<ruby>[ \t]*\n?" "\n?[ \t]*</ruby>" "ruby")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5641 ("^#\\+begin_src\\( \\([^ \t\n]+\\)\\)?.*\n" "\n#\\+end_src" 2)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5642 ("^#\\+begin_example.*\n" "\n#\\+end_example" "fundamental")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5643 ("^#\\+html:" "\n" "html" single-line)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5644 ("^#\\+begin_html.*\n" "\n#\\+end_html" "html")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5645 ("^#\\+begin_latex.*\n" "\n#\\+end_latex" "latex")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5646 ("^#\\+latex:" "\n" "latex" single-line)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5647 ("^#\\+begin_ascii.*\n" "\n#\\+end_ascii" "fundamental")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5648 ("^#\\+ascii:" "\n" "ascii" single-line)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5649 )))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5650 (pos (point))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5651 re re1 re2 single beg end lang)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5652 (catch 'exit
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5653 (while (setq entry (pop re-list))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5654 (setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5655 single (nth 3 entry))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5656 (save-excursion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5657 (if (or (looking-at re1)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5658 (re-search-backward re1 nil t))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5659 (progn
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5660 (setq beg (match-end 0) lang (org-edit-src-get-lang lang))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5661 (if (and (re-search-forward re2 nil t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5662 (>= (match-end 0) pos))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5663 (throw 'exit (list beg (match-beginning 0) lang single))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5664 (if (or (looking-at re2)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5665 (re-search-forward re2 nil t))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5666 (progn
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5667 (setq end (match-beginning 0))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5668 (if (and (re-search-backward re1 nil t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5669 (<= (match-beginning 0) pos))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5670 (throw 'exit
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5671 (list (match-end 0) end
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5672 (org-edit-src-get-lang lang) single)))))))))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5673
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5674 (defun org-edit-src-get-lang (lang)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5675 "Extract the src language."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5676 (let ((m (match-string 0)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5677 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5678 ((stringp lang) lang)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5679 ((integerp lang) (match-string lang))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5680 ((and (eq lang 'lang)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5681 (string-match "\\<lang=\"\\([^ \t\n\"]+\\)\"" m))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5682 (match-string 1 m))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5683 ((and (eq lang 'style)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5684 (string-match "\\<style=\"\\([^ \t\n\"]+\\)\"" m))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5685 (match-string 1 m))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5686 (t "fundamental"))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
5687
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5688 (defun org-edit-src-exit ()
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5689 "Exit special edit and protect problematic lines."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5690 (interactive)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5691 (unless (buffer-base-buffer (current-buffer))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5692 (error "This is not an indirect buffer, something is wrong..."))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5693 (unless (> (point-min) 1)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5694 (error "This buffer is not narrowed, something is wrong..."))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5695 (goto-char (point-min))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5696 (if (looking-at "[ \t\n]*\n") (replace-match ""))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5697 (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match ""))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5698 (when (org-bound-and-true-p org-edit-src-force-single-line)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5699 (goto-char (point-min))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5700 (while (re-search-forward "\n" nil t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5701 (replace-match " "))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5702 (goto-char (point-min))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5703 (if (looking-at "\\s-*") (replace-match " "))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5704 (if (re-search-forward "\\s-+\\'" nil t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5705 (replace-match "")))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5706 (when (org-bound-and-true-p org-edit-src-from-org-mode)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5707 (goto-char (point-min))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5708 (while (re-search-forward (if (org-mode-p) "^\\(.\\)" "^\\([*#]\\)") nil t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5709 (replace-match ",\\1"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5710 (when font-lock-mode
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5711 (font-lock-unfontify-region (point-min) (point-max)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5712 (put-text-property (point-min) (point-max) 'font-lock-fontified t))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5713 (when (org-bound-and-true-p org-edit-src-picture)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5714 (goto-char (point-min))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5715 (while (re-search-forward "^" nil t)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5716 (replace-match ": "))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5717 (when font-lock-mode
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5718 (font-lock-unfontify-region (point-min) (point-max)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5719 (put-text-property (point-min) (point-max) 'font-lock-fontified t))
97027
adc2dffbdfc3 2008-07-25 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96975
diff changeset
5720 (kill-buffer (current-buffer))
adc2dffbdfc3 2008-07-25 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96975
diff changeset
5721 (and (org-mode-p) (org-restart-font-lock)))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
5722
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5723
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5724 ;;; The orgstruct minor mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5725
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5726 ;; 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
5727 ;; integrate the org-mode structure editing commands.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5728
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5729 ;; 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
5730 ;; 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
5731 ;; 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
5732 ;; 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
5733 ;; 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
5734 ;; 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
5735 ;; 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
5736 ;; 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
5737 ;; 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
5738 ;; 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
5739 ;; 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
5740 ;; 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
5741 ;; used as a prefix key.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5742
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5743 ;; 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
5744 ;; 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
5745 ;; 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
5746
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5747 (defvar orgstruct-mode-map (make-sparse-keymap)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5748 "Keymap for the minor `orgstruct-mode'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5749
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5750 (defvar org-local-vars nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5751 "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
5752
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5753 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5754 (define-minor-mode orgstruct-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5755 "Toggle the minor more `orgstruct-mode'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5756 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
5757 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
5758 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
5759 of Org-mode).
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5760
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5761 M-up Move entry/item up
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5762 M-down Move entry/item down
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5763 M-left Promote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5764 M-right Demote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5765 M-S-up Move entry/item up
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5766 M-S-down Move entry/item down
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5767 M-S-left Promote subtree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5768 M-S-right Demote subtree
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5769 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
5770 C-c ^ Sort entries
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5771 C-c - Cycle list bullet
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5772 TAB Cycle item visibility
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5773 M-RET Insert new heading/item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5774 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
5775 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
5776 nil " OrgStruct" nil
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5777 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5778 (and (orgstruct-setup) (defun orgstruct-setup () nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5779
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5780 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5781 (defun turn-on-orgstruct ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5782 "Unconditionally turn on `orgstruct-mode'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5783 (orgstruct-mode 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5784
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5785 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5786 (defun turn-on-orgstruct++ ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5787 "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
5788 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
5789 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
5790 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
5791 (orgstruct-mode 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5792 (let (var val)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5793 (mapc
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5794 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5795 (when (string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5796 "^\\(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
5797 (symbol-name (car x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5798 (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
5799 (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
5800 org-local-vars)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5801
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5802 (defun orgstruct-error ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5803 "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
5804 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5805 (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
5806
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5807 (defun orgstruct-setup ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5808 "Setup orgstruct keymaps."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5809 (let ((nfunc 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5810 (bindings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5811 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5812 '([(meta up)] org-metaup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5813 '([(meta down)] org-metadown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5814 '([(meta left)] org-metaleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5815 '([(meta right)] org-metaright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5816 '([(meta shift up)] org-shiftmetaup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5817 '([(meta shift down)] org-shiftmetadown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5818 '([(meta shift left)] org-shiftmetaleft)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5819 '([(meta shift right)] org-shiftmetaright)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5820 '([(shift up)] org-shiftup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5821 '([(shift down)] org-shiftdown)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5822 '("\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
5823 '("\M-q" fill-paragraph)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5824 '("\C-c^" org-sort)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5825 '("\C-c-" org-cycle-list-bullet)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5826 elt key fun cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5827 (while (setq elt (pop bindings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5828 (setq nfunc (1+ nfunc))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5829 (setq key (org-key (car elt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5830 fun (nth 1 elt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5831 cmd (orgstruct-make-binding fun nfunc key))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5832 (org-defkey orgstruct-mode-map key cmd))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5833
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5834 ;; Special treatment needed for TAB and RET
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5835 (org-defkey orgstruct-mode-map [(tab)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5836 (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
5837 (org-defkey orgstruct-mode-map "\C-i"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5838 (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
5839
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5840 (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
5841 (orgstruct-make-binding 'org-insert-heading 105
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5842 "\M-\C-m" [(meta return)]))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5843 (org-defkey orgstruct-mode-map [(meta return)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5844 (orgstruct-make-binding 'org-insert-heading 106
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5845 [(meta return)] "\M-\C-m"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5846
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5847 (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
5848 (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
5849 [(meta return)] "\M-\C-m"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5850
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5851 (unless org-local-vars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5852 (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
5853
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5854 t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5855
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5856 (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
5857 "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
5858 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
5859 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
5860 to execute outside of tables."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5861 (eval
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5862 (list 'defun
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5863 (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
5864 '(arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5865 (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
5866 "Outside of structure, run the binding of `"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5867 (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
5868 "'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5869 '(interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5870 (list 'if
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5871 '(org-context-p 'headline 'item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5872 (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
5873 (list 'let '(orgstruct-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5874 (list 'call-interactively
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5875 (append '(or)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5876 (mapcar (lambda (k)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5877 (list 'key-binding k))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5878 keys)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5879 '('orgstruct-error))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5880
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5881 (defun org-context-p (&rest contexts)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5882 "Check if local context is any of CONTEXTS.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5883 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
5884 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5885 (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5886 (prog1 (or (and (memq 'table contexts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5887 (looking-at "[ \t]*|"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5888 (and (memq 'headline contexts)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5889 ;;????????? (looking-at "\\*+"))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
5890 (looking-at outline-regexp))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5891 (and (memq 'item contexts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5892 (looking-at "[ \t]*\\([-+*] \\|[0-9]+[.)] \\)")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5893 (goto-char pos))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5894
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5895 (defun org-get-local-variables ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5896 "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
5897 (let (varlist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5898 (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
5899 (erase-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5900 (org-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5901 (setq varlist (buffer-local-variables)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5902 (kill-buffer "*Org tmp*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5903 (delq nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5904 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5905 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5906 (setq x
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5907 (if (symbolp x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5908 (list x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5909 (list (car x) (list 'quote (cdr x)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5910 (if (string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5911 "^\\(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
5912 (symbol-name (car x)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5913 x nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5914 varlist))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5915
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5916 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5917 (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
5918 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5919 (unless org-local-vars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5920 (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
5921 (eval (list 'let org-local-vars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5922 (list 'call-interactively (list 'quote cmd)))))
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 ;;;; Archiving
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5925
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
5926 (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
5927 "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
5928 (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
5929
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5930 (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
5931 "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
5932 (let ((def-cat (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5933 ((null org-category)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5934 (if buffer-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5935 (file-name-sans-extension
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5936 (file-name-nondirectory buffer-file-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5937 "???"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5938 ((symbolp org-category) (symbol-name org-category))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5939 (t org-category)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5940 beg end cat pos optionp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5941 (org-unmodified
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5942 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5943 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5944 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5945 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5946 (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
5947 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5948 "^\\(#\\+CATEGORY:\\|[ \t]*:CATEGORY:\\)\\(.*\\)" nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5949 (setq pos (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5950 optionp (equal (char-after (match-beginning 0)) ?#)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5951 cat (org-trim (match-string 2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5952 (if optionp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5953 (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
5954 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5955 (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
5956 (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
5957 (goto-char pos)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5958
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5959
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5960 ;;;; Link Stuff
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5961
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5962 ;;; Link abbreviations
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5963
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5964 (defun org-link-expand-abbrev (link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5965 "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
5966 (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
5967 (let* ((key (match-string 1 link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5968 (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
5969 (assoc key org-link-abbrev-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5970 (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
5971 rpl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5972 (if (not as)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5973 link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5974 (setq rpl (cdr as))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5975 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5976 ((symbolp rpl) (funcall rpl tag))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5977 ((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
5978 (t (concat rpl tag)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5979 link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5980
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5981 ;;; Storing and inserting links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5982
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5983 (defvar org-insert-link-history nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5984 "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
5985
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5986 (defvar org-stored-links nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5987 "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
5988
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5989 (defvar org-store-link-plist nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5990 "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
5991
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5992 (defvar org-link-protocols nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5993 "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
5994
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5995 (defvar org-store-link-functions nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5996 "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
5997 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
5998 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
5999 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
6000 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
6001 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
6002 `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
6003 Special properties are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6004
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6005 :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
6006 :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
6007 This is obligatory as well.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6008 :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
6009 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
6010 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
6011
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6012 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
6013 and then used in remember templates.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6014
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6015 (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
6016 "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
6017 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
6018
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6019 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
6020
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6021 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
6022 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
6023 a mail message.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6024
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6025 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
6026 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
6027
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6028 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
6029 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
6030 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
6031
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6032 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
6033 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
6034 the exported file.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6035 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
6036 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
6037 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
6038 (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
6039 (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
6040 (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
6041 (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
6042 (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
6043
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6044
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6045 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6046 (defun org-store-link (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6047 "\\<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
6048 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
6049 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
6050
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6051 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
6052 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
6053 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
6054 (interactive "P")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6055 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6056 (setq org-store-link-plist nil) ; reset
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6057 (let (link cpltxt desc description search txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6058 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6059
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6060 ((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
6061 (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
6062 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
6063
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6064 ((eq major-mode 'calendar-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6065 (let ((cd (calendar-cursor-to-date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6066 (setq link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6067 (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6068 (car org-time-stamp-formats)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6069 (apply 'encode-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6070 (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
6071 nil nil nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6072 (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
6073
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6074 ((eq major-mode 'w3-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6075 (setq cpltxt (url-view-url t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6076 link (org-make-link cpltxt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6077 (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
6078
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6079 ((eq major-mode 'w3m-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6080 (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
6081 link (org-make-link w3m-current-url))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6082 (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
6083
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6084 ((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
6085 'org-create-file-search-functions))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6086 (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
6087 "::" search))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6088 (setq cpltxt (or description link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6089
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6090 ((eq major-mode 'image-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6091 (setq cpltxt (concat "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6092 (abbreviate-file-name buffer-file-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6093 link (org-make-link cpltxt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6094 (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
6095
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6096 ((eq major-mode 'dired-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6097 ;; 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
6098 (setq cpltxt (concat "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6099 (abbreviate-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6100 (expand-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6101 (dired-get-filename nil t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6102 link (org-make-link cpltxt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6103
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6104 ((and buffer-file-name (org-mode-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6105 ;; Just link to current headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6106 (setq cpltxt (concat "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6107 (abbreviate-file-name buffer-file-name)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6108 ;; Add a context search string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6109 (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
6110 ;; Check if we are on a target
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6111 (if (org-in-regexp "<<\\(.*?\\)>>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6112 (setq cpltxt (concat cpltxt "::" (match-string 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6113 (setq txt (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6114 ((org-on-heading-p) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6115 ((org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6116 (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
6117 (t nil)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6118 (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
6119 (setq cpltxt
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
6120 (concat cpltxt "::"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
6121 (condition-case nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
6122 (org-make-org-heading-search-string txt)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
6123 (error "")))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6124 desc "NONE"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6125 (if (string-match "::\\'" cpltxt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6126 (setq cpltxt (substring cpltxt 0 -2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6127 (setq link (org-make-link cpltxt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6128
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6129 ((buffer-file-name (buffer-base-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6130 ;; Just link to this file here.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6131 (setq cpltxt (concat "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6132 (abbreviate-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6133 (buffer-file-name (buffer-base-buffer)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6134 ;; Add a context string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6135 (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
6136 (setq txt (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6137 (buffer-substring (region-beginning) (region-end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6138 (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
6139 ;; 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
6140 (when (string-match "\\S-" txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6141 (setq cpltxt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6142 (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
6143 desc "NONE")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6144 (setq link (org-make-link cpltxt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6145
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6146 ((interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6147 (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
6148
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6149 (t (setq link nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6150
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6151 (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
6152 (setq link (or link cpltxt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6153 desc (or desc cpltxt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6154 (if (equal desc "NONE") (setq desc nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6155
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6156 (if (and (interactive-p) link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6157 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6158 (setq org-stored-links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6159 (cons (list link desc) org-stored-links))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6160 (message "Stored: %s" (or desc link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6161 (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
6162
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6163 (defun org-store-link-props (&rest plist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6164 "Store link properties, extract names and addresses."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6165 (let (x adr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6166 (when (setq x (plist-get plist :from))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6167 (setq adr (mail-extract-address-components x))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6168 (setq plist (plist-put plist :fromname (car adr)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6169 (setq plist (plist-put plist :fromaddress (nth 1 adr))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6170 (when (setq x (plist-get plist :to))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6171 (setq adr (mail-extract-address-components x))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6172 (setq plist (plist-put plist :toname (car adr)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6173 (setq plist (plist-put plist :toaddress (nth 1 adr)))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6174 (let ((from (plist-get plist :from))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6175 (to (plist-get plist :to)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6176 (when (and from to org-from-is-user-regexp)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6177 (setq plist
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6178 (plist-put plist :fromto
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6179 (if (string-match org-from-is-user-regexp from)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6180 (concat "to %t")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6181 (concat "from %f"))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6182 (setq org-store-link-plist plist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6183
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6184 (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
6185 "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
6186 (let (key value)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6187 (while plist
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6188 (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
6189 (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
6190 (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
6191
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6192 (defun org-email-link-description (&optional fmt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6193 "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
6194 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
6195 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
6196 (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
6197 (let* ((p org-store-link-plist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6198 (to (plist-get p :toaddress))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6199 (from (plist-get p :fromaddress))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6200 (table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6201 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6202 (cons "%c" (plist-get p :fromto))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6203 (cons "%F" (plist-get p :from))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6204 (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
6205 (cons "%T" (plist-get p :to))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6206 (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
6207 (cons "%s" (plist-get p :subject))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6208 (cons "%m" (plist-get p :message-id)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6209 (when (string-match "%c" fmt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6210 ;; Check if the user wrote this message
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6211 (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
6212 (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
6213 (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
6214 (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
6215 (org-replace-escapes fmt table)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6216
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6217 (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
6218 "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
6219 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6220 (let ((s (or string (org-get-heading))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6221 (unless (and string (not heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6222 ;; 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
6223 (if (string-match org-todo-regexp s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6224 (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6225 (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
6226 (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6227 (setq s (org-trim s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6228 (if (string-match (concat "^\\(" org-quote-string "\\|"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6229 org-comment-string "\\)") s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6230 (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6231 (while (string-match org-ts-regexp s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6232 (setq s (replace-match "" t t s))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6233 (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
6234 (setq s (replace-match " " t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6235 (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
6236 (mapconcat 'identity (org-split-string s "[ \t]+") " ")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6237
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6238 (defun org-make-link (&rest strings)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6239 "Concatenate STRINGS."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6240 (apply 'concat strings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6241
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6242 (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
6243 "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
6244 (unless (string-match "\\S-" link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6245 (error "Empty link"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6246 (when (stringp description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6247 ;; 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
6248 (while (string-match "\\[" description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6249 (setq description (replace-match "{" t t description)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6250 (while (string-match "\\]" description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6251 (setq description (replace-match "}" t t description))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6252 (when (equal (org-link-escape link) description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6253 ;; No description needed, it is identical
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6254 (setq description nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6255 (when (and (not description)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6256 (not (equal link (org-link-escape link))))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6257 (setq description (org-extract-attributes link)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6258 (concat "[[" (org-link-escape link) "]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6259 (if description (concat "[" description "]") "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6260 "]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6261
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6262 (defconst org-link-escape-chars
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6263 '((?\ . "%20")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6264 (?\[ . "%5B")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6265 (?\] . "%5D")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6266 (?\340 . "%E0") ; `a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6267 (?\342 . "%E2") ; ^a
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6268 (?\347 . "%E7") ; ,c
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6269 (?\350 . "%E8") ; `e
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6270 (?\351 . "%E9") ; 'e
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6271 (?\352 . "%EA") ; ^e
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6272 (?\356 . "%EE") ; ^i
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6273 (?\364 . "%F4") ; ^o
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6274 (?\371 . "%F9") ; `u
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6275 (?\373 . "%FB") ; ^u
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6276 (?\; . "%3B")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6277 (?? . "%3F")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6278 (?= . "%3D")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6279 (?+ . "%2B")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6280 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6281 "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
6282 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
6283
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6284 (defconst org-link-escape-chars-browser
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6285 '((?\ . "%20")) ; 32 for the SPC char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6286 "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
6287 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
6288
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6289 (defun org-link-escape (text &optional table)
99514
f726e2602732 * org.el (org-link-escape): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 99501
diff changeset
6290 "Escape characters in TEXT that are problematic for links."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6291 (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
6292 (when text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6293 (let ((re (mapconcat (lambda (x) (regexp-quote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6294 (char-to-string (car x))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6295 table "\\|")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6296 (while (string-match re text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6297 (setq text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6298 (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6299 (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
6300 table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6301 t t text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6302 text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6303
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6304 (defun org-link-unescape (text &optional table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6305 "Reverse the action of `org-link-escape'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6306 (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
6307 (when text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6308 (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
6309 table "\\|")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6310 (while (string-match re text)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6311 (setq text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6312 (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6313 (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
6314 t t text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6315 text)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6316
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6317 (defun org-xor (a b)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6318 "Exclusive or."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6319 (if a (not b) b))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6320
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6321 (defun org-get-header (header)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6322 "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
6323 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6324 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6325 (let ((case-fold-search t) s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6326 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6327 ((eq header 'from)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6328 (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
6329 (setq s (match-string 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6330 (while (string-match "\"" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6331 (setq s (replace-match "" t t s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6332 (if (string-match "[<(].*" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6333 (setq s (replace-match "" t t s))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6334 ((eq header 'message-id)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6335 (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
6336 (setq s (match-string 1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6337 ((eq header 'subject)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6338 (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
6339 (setq s (match-string 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6340 (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
6341 (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
6342 s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6343
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6344
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6345 (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
6346 "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
6347 (while (string-match "<" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6348 (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
6349 (while (string-match ">" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6350 (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
6351 (while (string-match "@" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6352 (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
6353 s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6354
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6355 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6356 (defun org-insert-link-global ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6357 "Insert a link like Org-mode does.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6358 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
6359 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6360 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6361 (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
6362
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6363 (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
6364 "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
6365
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6366 Completion can be used to insert any of the link protocol prefixes like
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6367 http or ftp in use.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6368
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6369 The history can be used to select a link previously stored with
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6370 `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
6371 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
6372 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
6373 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
6374
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6375 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
6376 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
6377
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6378 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
6379 and description parts.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6380
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6381 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
6382 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
6383 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
6384 Otherwise, the link will be the absolute path as completed in the minibuffer
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6385 \(i.e. normally ~/path/to/file). You can configure this behavior using the
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6386 option `org-link-file-path-type'.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6387
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6388 With two \\[universal-argument] prefixes, enforce an absolute path even if the file is in
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6389 the current directory or below.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6390
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6391 With three \\[universal-argument] prefixes, negate the meaning of
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6392 `org-keep-stored-link-after-insertion'.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6393
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6394 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
6395 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
6396 link description.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6397
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6398 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
6399 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
6400 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6401 (let* ((wcf (current-window-configuration))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6402 (region (if (org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6403 (buffer-substring (region-beginning) (region-end))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6404 (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
6405 (desc region)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6406 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
6407 (link link-location)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6408 entry file)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6409 (cond
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6410 (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
6411 ((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
6412 ;; 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
6413 (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
6414 (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
6415 (setq link (read-string "Link: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6416 (org-link-unescape
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6417 (org-match-string-no-properties 1)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6418 ((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
6419 (org-in-regexp org-plain-link-re))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6420 ;; Convert to bracket link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6421 (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
6422 link (read-string "Link: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6423 (org-remove-angle-brackets (match-string 0)))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6424 ((member complete-file '((4) (16)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6425 ;; Completing read for file names.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6426 (setq file (read-file-name "File: "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6427 (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
6428 (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
6429 (expand-file-name ".")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6430 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6431 ((equal complete-file '(16))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6432 (setq link (org-make-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6433 "file:"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6434 (abbreviate-file-name (expand-file-name file)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6435 ((string-match (concat "^" (regexp-quote pwd1) "\\(.+\\)") file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6436 (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
6437 ((string-match (concat "^" (regexp-quote pwd) "\\(.+\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6438 (expand-file-name file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6439 (setq link (org-make-link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6440 "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
6441 (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
6442 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6443 ;; Read link, with completion for stored links.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6444 (with-output-to-temp-buffer "*Org Links*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6445 (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
6446 (when org-stored-links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6447 (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
6448 (princ (mapconcat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6449 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6450 (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
6451 (reverse org-stored-links) "\n"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6452 (let ((cw (selected-window)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6453 (select-window (get-buffer-window "*Org Links*"))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6454 (org-fit-window-to-buffer)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6455 (setq truncate-lines t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6456 (select-window cw))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6457 ;; 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
6458 (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
6459 org-insert-link-history))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6460 (unwind-protect
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6461 (setq link (org-completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6462 "Link: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6463 (append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6464 (mapcar (lambda (x) (list (concat (car x) ":")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6465 (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
6466 (mapcar (lambda (x) (list (concat x ":")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6467 org-link-types))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6468 nil nil nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6469 'tmphist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6470 (or (car (car org-stored-links)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6471 (set-window-configuration wcf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6472 (kill-buffer "*Org Links*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6473 (setq entry (assoc link org-stored-links))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6474 (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
6475 (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
6476 (not org-keep-stored-link-after-insertion))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6477 (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
6478 org-stored-links)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6479 (setq desc (or desc (nth 1 entry)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6480
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6481 (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
6482 ;; 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
6483 (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
6484
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6485 ;; 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
6486 ;; 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
6487 (when (and buffer-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6488 (string-match "\\<file:\\(.+?\\)::\\([^>]+\\)" link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6489 (let* ((path (match-string 1 link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6490 (case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6491 (search (match-string 2 link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6492 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6493 (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
6494 ;; 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
6495 (setq link search)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6496
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6497 ;; 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
6498 (when (string-match "\\<file:\\(.*\\)" link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6499 (let* ((path (match-string 1 link))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6500 (origpath path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6501 (case-fold-search nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6502 (cond
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6503 ((or (eq org-link-file-path-type 'absolute)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6504 (equal complete-file '(16)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6505 (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
6506 ((eq org-link-file-path-type 'noabbrev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6507 (setq path (expand-file-name path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6508 ((eq org-link-file-path-type 'relative)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6509 (setq path (file-relative-name path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6510 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6511 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6512 (if (string-match (concat "^" (regexp-quote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6513 (file-name-as-directory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6514 (expand-file-name "."))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6515 (expand-file-name path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6516 ;; 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
6517 (setq path (substring (expand-file-name path)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6518 (match-end 0)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6519 (setq path (abbreviate-file-name (expand-file-name path)))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6520 (setq link (concat "file:" path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6521 (if (equal desc origpath)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6522 (setq desc path))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6523
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6524 (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
6525 (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
6526
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6527 (setq desc (read-string "Description: " desc))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6528 (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
6529 (if remove (apply 'delete-region remove))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6530 (insert (org-make-link-string link desc))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6531
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6532 (defun org-completing-read (&rest args)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6533 "Completing-read with SPACE being a normal character."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6534 (let ((minibuffer-local-completion-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6535 (copy-keymap minibuffer-local-completion-map)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6536 (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
6537 (apply 'completing-read args)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6538
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6539 (defun org-extract-attributes (s)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6540 "Extract the attributes cookie from a string and set as text property."
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
6541 (let (a attr (start 0) key value)
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6542 (save-match-data
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6543 (when (string-match "{{\\([^}]+\\)}}$" s)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6544 (setq a (match-string 1 s) s (substring s 0 (match-beginning 0)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6545 (while (string-match "\\([a-zA-Z]+\\)=\"\\([^\"]*\\)\"" a start)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6546 (setq key (match-string 1 a) value (match-string 2 a)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6547 start (match-end 0)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6548 attr (plist-put attr (intern key) value))))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6549 (org-add-props s nil 'org-attributes attr))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6550 s))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6551
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6552 (defun org-attributes-to-string (plist)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6553 "Format a property list into an HTML attribute list."
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6554 (let ((s "") key value)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6555 (while plist
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6556 (setq key (pop plist) value (pop plist))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6557 (setq s (concat s " "(symbol-name key) "=\"" value "\"")))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6558 s))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6559
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6560 ;;; 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
6561
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6562 (defvar org-link-search-failed nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6563
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6564 (defun org-next-link ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6565 "Move forward to the next link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6566 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
6567 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6568 (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
6569 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6570 (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
6571 (setq org-link-search-failed nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6572 (let* ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6573 (ct (org-context))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6574 (a (assoc :link ct)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6575 (if a (goto-char (nth 2 a)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6576 (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
6577 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6578 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6579 (if (org-invisible-p) (org-show-context)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6580 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6581 (setq org-link-search-failed t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6582 (error "No further link found"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6583
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6584 (defun org-previous-link ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6585 "Move backward to the previous link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6586 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
6587 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6588 (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
6589 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6590 (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
6591 (setq org-link-search-failed nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6592 (let* ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6593 (ct (org-context))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6594 (a (assoc :link ct)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6595 (if a (goto-char (nth 1 a)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6596 (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
6597 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6598 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6599 (if (org-invisible-p) (org-show-context)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6600 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6601 (setq org-link-search-failed t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6602 (error "No further link found"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6603
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6604 (defun org-find-file-at-mouse (ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6605 "Open file link or URL at mouse."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6606 (interactive "e")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6607 (mouse-set-point ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6608 (org-open-at-point 'in-emacs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6609
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6610 (defun org-open-at-mouse (ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6611 "Open file link or URL at mouse."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6612 (interactive "e")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6613 (mouse-set-point ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6614 (org-open-at-point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6615
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6616 (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
6617 "The window configuration before following a link.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6618 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
6619
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6620 (defvar org-open-link-marker (make-marker)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6621 "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
6622
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6623 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6624 (defun org-open-at-point-global ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6625 "Follow a link like Org-mode does.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6626 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
6627 Org-mode syntax."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6628 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6629 (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
6630
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6631 ;;;###autoload
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6632 (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
6633 "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
6634 (interactive "sLink: \nP")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6635 (with-temp-buffer
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6636 (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
6637 (org-mode)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6638 (insert s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6639 (goto-char (point-min))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6640 (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
6641
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6642 (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
6643 "Open link at or after point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6644 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
6645 the end of the current subtree.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6646 Normally, files will be opened by an appropriate application. If the
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6647 optional argument IN-EMACS is non-nil, Emacs will visit the file.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6648 With a double prefix argument, try to open outside of Emacs, in the
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
6649 application the system uses for this file type."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6650 (interactive "P")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6651 (org-load-modules-maybe)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6652 (move-marker org-open-link-marker (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6653 (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
6654 (org-remove-occur-highlights nil nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6655 (if (org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6656 (org-follow-timestamp-link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6657 (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
6658 (catch 'match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6659 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6660 (skip-chars-forward "^]\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6661 (when (org-in-regexp org-bracket-link-regexp)
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6662 (setq link (org-extract-attributes
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6663 (org-link-unescape (org-match-string-no-properties 1))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6664 (while (string-match " *\n *" link)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6665 (setq link (replace-match " " t t link)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6666 (setq link (org-link-expand-abbrev link))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6667 (cond
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6668 ((or (file-name-absolute-p link)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6669 (string-match "^\\.\\.?/" link))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6670 (setq type "file" path link))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6671 ((string-match org-link-re-with-space2 link)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6672 (setq type (match-string 1 link) path (match-string 2 link)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
6673 (t (setq type "thisfile" path link)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6674 (throw 'match t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6675
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6676 (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
6677 (setq type "thisfile"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6678 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
6679 (1+ (point)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6680 path (buffer-substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6681 (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
6682 (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
6683 (throw 'match t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6684
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6685 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6686 (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
6687 (org-in-regexp org-plain-link-re))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6688 (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
6689 (throw 'match t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6690 (when (org-in-regexp "\\<\\([^><\n]+\\)\\>")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6691 (setq type "tree-match"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6692 path (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6693 (throw 'match t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6694 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6695 (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
6696 (setq type "tags"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6697 path (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6698 (while (string-match ":" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6699 (setq path (replace-match "+" t t path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6700 (throw 'match t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6701 (unless path
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6702 (error "No link found"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6703 ;; Remove any trailing spaces in path
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6704 (if (string-match " +\\'" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6705 (setq path (replace-match "" t t path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6706
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6707 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6708
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6709 ((assoc type org-link-protocols)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6710 (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
6711
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6712 ((equal type "mailto")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6713 (let ((cmd (car org-link-mailto-program))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6714 (args (cdr org-link-mailto-program)) args1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6715 (address path) (subject "") a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6716 (if (string-match "\\(.*\\)::\\(.*\\)" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6717 (setq address (match-string 1 path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6718 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
6719 (while args
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6720 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6721 ((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
6722 (t (setq a (pop args))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6723 (if (string-match "%a" a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6724 (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
6725 (if (string-match "%s" a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6726 (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
6727 (push a args1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6728 (apply cmd (nreverse args1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6729
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6730 ((member type '("http" "https" "ftp" "news"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6731 (browse-url (concat type ":" (org-link-escape
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6732 path org-link-escape-chars-browser))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6733
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6734 ((member type '("message"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6735 (browse-url (concat type ":" path)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6736
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6737 ((string= type "tags")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6738 (org-tags-view in-emacs path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6739 ((string= type "thisfile")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6740 (if in-emacs
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6741 (switch-to-buffer-other-window
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6742 (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
6743 (org-mark-ring-push))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6744 (let ((cmd `(org-link-search
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6745 ,path
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6746 ,(cond ((equal in-emacs '(4)) 'occur)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6747 ((equal in-emacs '(16)) 'org-occur)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6748 (t nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6749 ,pos)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6750 (condition-case nil (eval cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6751 (error (progn (widen) (eval cmd))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6752
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6753 ((string= type "tree-match")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6754 (org-occur (concat "\\[" (regexp-quote path) "\\]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6755
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6756 ((string= type "file")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6757 (if (string-match "::\\([0-9]+\\)\\'" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6758 (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
6759 path (substring path 0 (match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6760 (if (string-match "::\\(.+\\)\\'" path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6761 (setq search (match-string 1 path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6762 path (substring path 0 (match-beginning 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6763 (if (string-match "[*?{]" (file-name-nondirectory path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6764 (dired path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6765 (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
6766
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6767 ((string= type "news")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6768 (require 'org-gnus)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6769 (org-gnus-follow-link path))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6770
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6771 ((string= type "shell")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6772 (let ((cmd path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6773 (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
6774 (funcall org-confirm-shell-link-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6775 (format "Execute \"%s\" in shell? "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6776 (org-add-props cmd nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6777 'face 'org-warning))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6778 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6779 (message "Executing %s" cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6780 (shell-command cmd))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6781 (error "Abort"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6782
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6783 ((string= type "elisp")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6784 (let ((cmd path))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6785 (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
6786 (funcall org-confirm-elisp-link-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6787 (format "Execute \"%s\" as elisp? "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6788 (org-add-props cmd nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6789 'face 'org-warning))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6790 (message "%s => %s" cmd (eval (read cmd)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6791 (error "Abort"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6792
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6793 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6794 (browse-url-at-point)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6795 (move-marker org-open-link-marker nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6796 (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
6797
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6798 ;;;; Time estimates
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6799
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6800 (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
6801 "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
6802 (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
6803
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6804 ;;; File search
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 (defvar org-create-file-search-functions nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6807 "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
6808 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
6809 which the link should point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6810
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6811 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
6812 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
6813 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
6814 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
6815 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
6816 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
6817 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
6818 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
6819 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
6820 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
6821 which see.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6822
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6823 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
6824 `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
6825 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
6826 buffer with \\[org-insert-link].")
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 (defvar org-execute-file-search-functions nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6829 "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
6830
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6831 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
6832 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
6833 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
6834 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
6835 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
6836 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
6837 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
6838 other functions from trying.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6839
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6840 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
6841 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
6842 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
6843 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
6844
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6845 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
6846 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
6847
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6848 (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
6849
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6850 (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
6851 "Search for a link search option.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6852 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
6853 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
6854 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
6855 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
6856 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
6857 (let ((case-fold-search t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6858 (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
6859 (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
6860 (append '(("") (" ") ("\t") ("\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6861 org-emphasis-alist)
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 (pos (point))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6864 (pre nil) (post nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6865 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
6866 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6867 ;; First check if there are any special
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6868 ((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
6869 ;; Now try the builtin stuff
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6870 ((save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6871 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6872 (and
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6873 (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6874 (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
6875 (setq type 'dedicated
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6876 pos (match-beginning 0))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6877 ;; There is an exact target for this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6878 (goto-char pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6879 ((string-match "^/\\(.*\\)/$" s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6880 ;; A regular expression
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6881 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6882 ((org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6883 (org-occur (match-string 1 s)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6884 ;;((eq major-mode 'dired-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6885 ;; (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
6886 (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
6887 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6888 ;; A normal search strings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6889 (when (equal (string-to-char s) ?*)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6890 ;; Anchor on headlines, post may include tags.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6891 (setq pre "^\\*+[ \t]+\\(?:\\sw+\\)?[ \t]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6892 post (org-re "[ \t]*\\(?:[ \t]+:[[:alnum:]_@:+]:[ \t]*\\)?$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6893 s (substring s 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6894 (remove-text-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6895 0 (length s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6896 '(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
6897 ;; 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
6898 (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
6899
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6900 re0 (concat "\\(<<" (regexp-quote s0) ">>\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6901 re2 (concat markers "\\(" (mapconcat 'downcase words "[ \t]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6902 "\\)" markers)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6903 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
6904 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
6905 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
6906 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
6907
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6908 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
6909 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
6910 re5 (concat pre ".*" re4)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6911 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
6912 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
6913 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
6914 reall (concat "\\(" re0 "\\)\\|\\(" re1 "\\)\\|\\(" re2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6915 "\\)\\|\\(" re3 "\\)\\|\\(" re4 "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6916 re5 "\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6917 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6918 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6919 ((eq type 'org-occur) (org-occur reall))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6920 ((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
6921 (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
6922 (setq type 'fuzzy)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6923 (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
6924 (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
6925 (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
6926 (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
6927 (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
6928 (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
6929 (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
6930 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6931 (goto-char (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6932 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6933 (error "No match")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6934 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6935 ;; Normal string-search
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6936 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6937 (if (search-forward s nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6938 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6939 (error "No match"))))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
6940 (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
6941 type))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6942
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6943 (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
6944 "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
6945 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
6946 (let ((m org-open-link-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6947 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6948 (while (apply 're-search-forward args)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6949 (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
6950 (goto-char (match-end group))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6951 (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
6952 (> (match-beginning 0) (marker-position m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6953 (< (match-end 0) (marker-position m)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6954 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6955 (or (not (org-in-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6956 org-bracket-link-analytic-regexp 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6957 (not (match-end 4)) ; no description
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6958 (and (<= (match-beginning 4) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6959 (>= (match-end 4) (point))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6960 (throw 'exit (point))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6961
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6962 (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
6963 "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
6964 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6965 ((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
6966 buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6967 ((string-match "(Clone)$" (buffer-name buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6968 (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
6969 ;; 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
6970 buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6971 (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
6972 (let* ((bn (buffer-name buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6973 (ibn (concat bn "(Clone)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6974 (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
6975 (with-current-buffer ib (org-overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6976 ib))))
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-do-occur (regexp &optional cleanup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6979 "Call the Emacs command `occur'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6980 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
6981 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
6982 to read."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6983 (occur regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6984 (when cleanup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6985 (let ((cwin (selected-window)) win beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6986 (when (setq win (get-buffer-window "*Occur*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6987 (select-window win))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6988 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6989 (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
6990 (setq beg (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6991 (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
6992 (setq end (1- (match-beginning 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6993 (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
6994 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6995 (select-window cwin))))
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 ;;; The mark ring for links jumps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6998
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6999 (defvar org-mark-ring nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7000 "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
7001 (defvar org-mark-ring-last-goto nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7002 "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
7003 ;; Fill and close the ring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7004 (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
7005 (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
7006 (push (make-marker) org-mark-ring))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7007 (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
7008 org-mark-ring)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7009
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7010 (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
7011 "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
7012 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7013 (setq pos (or pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7014 (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
7015 (move-marker (car org-mark-ring)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7016 (or pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7017 (or buffer (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7018 (message "%s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7019 (substitute-command-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7020 "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
7021
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7022 (defun org-mark-ring-goto (&optional n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7023 "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
7024 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
7025 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
7026 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
7027 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
7028 onto the ring."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7029 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7030 (let (p m)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7031 (if (eq last-command this-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7032 (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
7033 (setq p org-mark-ring))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7034 (setq org-mark-ring-last-goto p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7035 (setq m (car p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7036 (switch-to-buffer (marker-buffer m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7037 (goto-char m)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7038 (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
7039
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7040 (defun org-remove-angle-brackets (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7041 (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
7042 (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
7043 s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7044 (defun org-add-angle-brackets (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7045 (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
7046 (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
7047 s)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7048 (defun org-remove-double-quotes (s)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7049 (if (equal (substring s 0 1) "\"") (setq s (substring s 1)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7050 (if (equal (substring s -1) "\"") (setq s (substring s 0 -1)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7051 s)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7052
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7053 ;;; Following specific links
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7054
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7055 (defun org-follow-timestamp-link ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7056 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7057 ((org-at-date-range-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7058 (let ((org-agenda-start-on-weekday)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7059 (t1 (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7060 (t2 (match-string 2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7061 (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
7062 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
7063 (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
7064 ((org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7065 (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
7066 (substring (match-string 1) 0 10)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7067 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7068 (t (error "This should not happen"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7069
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7070
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7071 ;;; Following file links
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7072 (defvar org-wait nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7073 (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
7074 "Open the file at PATH.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7075 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
7076 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
7077 entry for this file type, and if yes, the corresponding command is launched.
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7078
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7079 If no application is found, Emacs simply visits the file.
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7080
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7081 With optional prefix argument IN-EMACS, Emacs will visit the file.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7082 With a double C-c C-u prefix arg, Org tries to avoid opening in Emacs
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7083 and o use an external application to visit the file.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7084
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7085 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
7086 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
7087 opened in Emacs.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7088 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
7089 (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
7090 (let* ((file (if (equal path "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7091 buffer-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7092 (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
7093 (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
7094 (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
7095 (dirp (if remp nil (file-directory-p file)))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
7096 (file (if (and dirp org-open-directory-means-index-dot-org)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
7097 (concat (file-name-as-directory file) "index.org")
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
7098 file))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7099 (a-m-a-p (assq 'auto-mode apps))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7100 (dfile (downcase file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7101 (old-buffer (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7102 (old-pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7103 (old-mode major-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7104 ext cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7105 (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
7106 (setq ext (match-string 1 dfile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7107 (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
7108 (setq ext (match-string 1 dfile))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7109 (cond
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7110 ((equal in-emacs '(16))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7111 (setq cmd (cdr (assoc 'system apps))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7112 (in-emacs (setq cmd 'emacs))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7113 (t
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7114 (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
7115 (and dirp (cdr (assoc 'directory apps)))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7116 (assoc-default dfile (org-apps-regexp-alist apps a-m-a-p)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7117 'string-match)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7118 (cdr (assoc ext apps))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7119 (cdr (assoc t apps))))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7120 (when (eq cmd 'system)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7121 (setq cmd (cdr (assoc 'system apps))))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7122 (when (eq cmd 'default)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7123 (setq cmd (cdr (assoc t apps))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7124 (when (eq cmd 'mailcap)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7125 (require 'mailcap)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7126 (mailcap-parse-mailcaps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7127 (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
7128 (command (mailcap-mime-info mime-type)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7129 (if (stringp command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7130 (setq cmd command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7131 (setq cmd 'emacs))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7132 (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
7133 (not (file-exists-p file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7134 (not org-open-non-existing-files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7135 (error "No such file: %s" file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7136 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7137 ((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
7138 ;; 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
7139 (while (string-match "['\"]%s['\"]" cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7140 (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
7141 (while (string-match "%s" cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7142 (setq cmd (replace-match
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7143 (save-match-data
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7144 (shell-quote-argument
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7145 (convert-standard-filename file)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7146 t t cmd)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7147 (save-window-excursion
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7148 (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
7149 (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
7150 ))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7151 ((or (stringp cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7152 (eq cmd 'emacs))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7153 (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
7154 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7155 (if line (goto-line line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7156 (if search (org-link-search search))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7157 ((consp cmd)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7158 (let ((file (convert-standard-filename file)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7159 (eval cmd)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7160 (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
7161 (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
7162 (or (not (equal old-buffer (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7163 (not (equal old-pos (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7164 (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
7165
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7166 (defun org-default-apps ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7167 "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
7168 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7169 ((eq system-type 'darwin)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7170 org-file-apps-defaults-macosx)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7171 ((eq system-type 'windows-nt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7172 org-file-apps-defaults-windowsnt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7173 (t org-file-apps-defaults-gnu)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7174
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7175 (defun org-apps-regexp-alist (list &optional add-auto-mode)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7176 "Convert extensions to regular expressions in the cars of LIST.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7177 Also, weed out any non-string entries, because the return value is used
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7178 only for regexp matching.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7179 When ADD-AUTO-MODE is set, make all matches in `auto-mode-alist'
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7180 point to the symbol `emacs', indicating that the file should
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7181 be opened in Emacs."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7182 (append
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7183 (delq nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7184 (mapcar (lambda (x)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7185 (if (not (stringp (car x)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7186 nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7187 (if (string-match "\\W" (car x))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7188 x
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7189 (cons (concat "\\." (car x) "\\'") (cdr x)))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7190 list))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7191 (if add-auto-mode
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7192 (mapcar (lambda (x) (cons (car x) 'emacs)) auto-mode-alist))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7193
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7194 (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
7195 (defun org-file-remote-p (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7196 "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
7197 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
7198
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7199 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
7200 on the system \"/user@host:\"."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7201 (cond ((fboundp 'file-remote-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7202 (file-remote-p file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7203 ((fboundp 'tramp-handle-file-remote-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7204 (tramp-handle-file-remote-p file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7205 ((and (boundp 'ange-ftp-name-format)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7206 (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
7207 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7208 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7209
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7210
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7211 ;;;; Refiling
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7212
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7213 (defun org-get-org-file ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7214 "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
7215 (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
7216 (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
7217 (file-name-as-directory org-directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7218 default)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7219
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7220 (defun org-notes-order-reversed-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7221 "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
7222 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7223 ((not org-reverse-note-order) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7224 ((eq t org-reverse-note-order) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7225 ((not (listp org-reverse-note-order)) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7226 (t (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7227 (let ((all org-reverse-note-order)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7228 entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7229 (while (setq entry (pop all))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7230 (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
7231 (throw 'exit (cdr entry))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7232 nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7233
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7234 (defvar org-refile-target-table nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7235 "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
7236
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7237 (defvar org-agenda-new-buffers nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7238 "Buffers created to visit agenda files.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7239
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7240 (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
7241 "Produce a table with refile targets."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7242 (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
7243 targets txt re files f desc descre)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7244 (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
7245 (while (setq entry (pop entries))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7246 (setq files (car entry) desc (cdr entry))
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 ((null files) (setq files (list (current-buffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7249 ((eq files 'org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7250 (setq files (org-agenda-files 'unrestricted)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7251 ((and (symbolp files) (fboundp files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7252 (setq files (funcall files)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7253 ((and (symbolp files) (boundp files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7254 (setq files (symbol-value files))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7255 (if (stringp files) (setq files (list files)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7256 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7257 ((eq (car desc) :tag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7258 (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
7259 ((eq (car desc) :todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7260 (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
7261 ((eq (car desc) :regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7262 (setq descre (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7263 ((eq (car desc) :level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7264 (setq descre (concat "^\\*\\{" (number-to-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7265 (if org-odd-levels-only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7266 (1- (* 2 (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7267 (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7268 "\\}[ \t]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7269 ((eq (car desc) :maxlevel)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7270 (setq descre (concat "^\\*\\{1," (number-to-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7271 (if org-odd-levels-only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7272 (1- (* 2 (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7273 (cdr desc)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7274 "\\}[ \t]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7275 (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
7276 (while (setq f (pop files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7277 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7278 (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
7279 (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
7280 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7281 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7282 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7283 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7284 (while (re-search-forward descre nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7285 (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7286 (when (looking-at org-complex-heading-regexp)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7287 (setq txt (org-link-display-format (match-string 4))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7288 re (concat "^" (regexp-quote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7289 (buffer-substring (match-beginning 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7290 (match-end 4)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7291 (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
7292 (regexp-quote
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7293 (match-string 5)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7294 (setq re (concat re "[ \t]*$"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7295 (when org-refile-use-outline-path
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7296 (setq txt (mapconcat 'org-protect-slash
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7297 (append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7298 (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
7299 (list (file-name-nondirectory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7300 (buffer-file-name (buffer-base-buffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7301 (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
7302 (list (buffer-file-name (buffer-base-buffer)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7303 (org-get-outline-path)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7304 (list txt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7305 "/")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7306 (push (list txt f re (point)) targets))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7307 (goto-char (point-at-eol))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7308 (nreverse targets))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7309
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7310 (defun org-protect-slash (s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7311 (while (string-match "/" s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7312 (setq s (replace-match "\\" t t s)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7313 s)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7314
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7315 (defun org-get-outline-path ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7316 "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
7317 (let (rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7318 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7319 (while (org-up-heading-safe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7320 (when (looking-at org-complex-heading-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7321 (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
7322 rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7323
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7324 (defvar org-refile-history nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7325 "History for refiling operations.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7326
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7327 (defun org-refile (&optional goto default-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7328 "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
7329 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
7330 `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
7331 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
7332
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7333 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
7334 Depending on `org-reverse-note-order', the new subitem will either be the
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
7335 first or the last subitem.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7336
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7337 If there is an active region, all entries in that region will be moved.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7338 However, the region must fulfil the requirement that the first heading
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7339 is the first one sets the top-level of the moved text - at most siblings
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7340 below it are allowed.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7341
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7342 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
7343 not actually move anything.
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7344 With a double prefix `C-u C-u', 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
7345 operation has put the subtree."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7346 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7347 (let* ((cbuf (current-buffer))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7348 (regionp (org-region-active-p))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7349 (region-start (and regionp (region-beginning)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7350 (region-end (and regionp (region-end)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7351 (region-length (and regionp (- region-end region-start)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7352 (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
7353 pos it nbuf file re level reversed)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7354 (when regionp (goto-char region-start)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7355 (unless (org-kill-is-subtree-p
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7356 (buffer-substring region-start region-end))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7357 (error "The region is not a (sequence of) subtree(s)")))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7358 (if (equal goto '(16))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7359 (org-refile-goto-last-stored)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7360 (when (setq it (org-refile-get-location
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7361 (if goto "Goto: " "Refile to: ") default-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7362 (setq file (nth 1 it)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7363 re (nth 2 it)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7364 pos (nth 3 it))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7365 (setq nbuf (or (find-buffer-visiting file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7366 (find-file-noselect file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7367 (if goto
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7368 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7369 (switch-to-buffer nbuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7370 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7371 (org-show-context 'org-goto))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7372 (if regionp
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7373 (progn
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7374 (kill-new (buffer-substring region-start region-end))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7375 (org-save-markers-in-region region-start region-end))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7376 (org-copy-subtree 1 nil t))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7377 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7378 (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
7379 (find-file-noselect file))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7380 (setq reversed (org-notes-order-reversed-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7381 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7382 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7383 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7384 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7385 (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7386 (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
7387 (goto-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7388 (if reversed
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7389 (or (outline-next-heading) (point-max))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7390 (or (save-excursion (outline-get-next-sibling))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7391 (org-end-of-subtree t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7392 (point-max))))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7393 (if (not (bolp)) (newline))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7394 (bookmark-set "org-refile-last-stored")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7395 (org-paste-subtree level))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7396 (if regionp
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7397 (delete-region (point) (+ (point) region-length))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7398 (org-cut-subtree))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7399 (setq org-markers-to-move nil)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7400 (message "Refiled to \"%s\"" (car it)))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7401
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7402 (defun org-refile-goto-last-stored ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7403 "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
7404 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7405 (bookmark-jump "org-refile-last-stored")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7406 (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
7407
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7408 (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
7409 "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
7410 (let ((org-refile-targets org-refile-targets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7411 (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
7412 (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
7413 (unless org-refile-target-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7414 (error "No refile targets"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7415 (let* ((cbuf (current-buffer))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7416 (cfunc (if org-refile-use-outline-path
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7417 'org-olpath-completing-read
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7418 'completing-read))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7419 (extra (if org-refile-use-outline-path "/" ""))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7420 (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
7421 (fname (and filename (file-truename filename)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7422 (tbl (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7423 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7424 (if (not (equal fname (file-truename (nth 1 x))))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7425 (cons (concat (car x) extra " ("
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7426 (file-name-nondirectory (nth 1 x)) ")")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7427 (cdr x))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7428 (cons (concat (car x) extra) (cdr x))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7429 org-refile-target-table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7430 (completion-ignore-case t))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7431 (assoc (funcall cfunc prompt tbl nil t nil 'org-refile-history)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7432 tbl)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7433
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7434 (defun org-olpath-completing-read (prompt collection &rest args)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7435 "Read an outline path like a file name."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7436 (let ((thetable collection))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7437 (apply
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7438 'completing-read prompt
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7439 (lambda (string predicate &optional flag)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7440 (let (rtn r s f (l (length string)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7441 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7442 ((eq flag nil)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7443 ;; try completion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7444 (try-completion string thetable))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7445 ((eq flag t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7446 ;; all-completions
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7447 (setq rtn (all-completions string thetable predicate))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7448 (mapcar
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7449 (lambda (x)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7450 (setq r (substring x l))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7451 (if (string-match " ([^)]*)$" x)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7452 (setq f (match-string 0 x))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7453 (setq f ""))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7454 (if (string-match "/" r)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7455 (concat string (substring r 0 (match-end 0)) f)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7456 x))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7457 rtn))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7458 ((eq flag 'lambda)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7459 ;; exact match?
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7460 (assoc string thetable)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7461 ))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7462 args)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7463
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7464 ;;;; Dynamic blocks
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-find-dblock (name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7467 "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
7468 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
7469 (let (pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7470 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7471 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7472 (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
7473 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7474 (match-beginning 0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7475 (if pos (goto-char pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7476 pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7477
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7478 (defconst org-dblock-start-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7479 "^#\\+BEGIN:[ \t]+\\(\\S-+\\)\\([ \t]+\\(.*\\)\\)?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7480 "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
7481
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7482 (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
7483 "Matches the end of a dyhamic block.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7484
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7485 (defun org-create-dblock (plist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7486 "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
7487 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
7488 (unless (bolp) (newline))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7489 (let ((name (plist-get plist :name)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7490 (insert "#+BEGIN: " name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7491 (while plist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7492 (if (eq (car plist) :name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7493 (setq plist (cddr plist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7494 (insert " " (prin1-to-string (pop plist)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7495 (insert "\n\n#+END:\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7496 (beginning-of-line -2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7497
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7498 (defun org-prepare-dblock ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7499 "Prepare dynamic block for refresh.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7500 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
7501 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
7502 (unless (looking-at org-dblock-start-re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7503 (error "Not at a dynamic block"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7504 (let* ((begdel (1+ (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7505 (name (org-no-properties (match-string 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7506 (params (append (list :name name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7507 (read (concat "(" (match-string 3) ")")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7508 (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
7509 (error "Dynamic block not terminated"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7510 (setq params
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7511 (append params
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7512 (list :content (buffer-substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7513 begdel (match-beginning 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7514 (delete-region begdel (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7515 (goto-char begdel)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7516 (open-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7517 params))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7518
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7519 (defun org-map-dblocks (&optional command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7520 "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
7521 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
7522 (let ((cmd (or command 'org-update-dblock))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7523 pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7524 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7525 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7526 (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
7527 (goto-char (setq pos (match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7528 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7529 (funcall cmd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7530 (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
7531 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7532 (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
7533 (error "Dynamic block not terminated"))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7534
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7535 (defun org-dblock-update (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7536 "User command for updating dynamic blocks.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7537 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
7538 blocks in the buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7539 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7540 (if arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7541 (org-update-all-dblocks)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7542 (or (looking-at org-dblock-start-re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7543 (org-beginning-of-dblock))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7544 (org-update-dblock)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7545
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7546 (defun org-update-dblock ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7547 "Update the dynamic block at point
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7548 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
7549 the correct writing function."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7550 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7551 (let* ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7552 (line (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7553 (params (org-prepare-dblock))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7554 (name (plist-get params :name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7555 (cmd (intern (concat "org-dblock-write:" name))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7556 (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
7557 (funcall cmd params)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7558 (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
7559 (goto-char pos))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7560
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7561 (defun org-beginning-of-dblock ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7562 "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
7563 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
7564 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7565 beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7566 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7567 (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
7568 (setq beg (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7569 (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
7570 (> (match-end 0) pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7571 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7572 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7573 (error "Not in a dynamic block"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7574
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7575 (defun org-update-all-dblocks ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7576 "Update all dynamic blocks in the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7577 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
7578 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7579 (org-map-dblocks 'org-update-dblock)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7580
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7581
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7582 ;;;; Completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7583
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7584 (defconst org-additional-option-like-keywords
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7585 '("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
7586 "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "TBLFM"
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7587 "BEGIN_EXAMPLE" "END_EXAMPLE"
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7588 "BEGIN_QUOTE" "END_QUOTE"
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7589 "BEGIN_VERSE" "END_VERSE"
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
7590 "BEGIN_SRC" "END_SRC"))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7591
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7592 (defcustom org-structure-template-alist
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7593 '(
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7594 ("s" "#+begin_src ?\n\n#+end_src"
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7595 "<src lang=\"?\">\n\n</src>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7596 ("e" "#+begin_example\n?\n#+end_example"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7597 "<example>\n?\n</example>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7598 ("q" "#+begin_quote\n?\n#+end_quote"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7599 "<quote>\n?\n</quote>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7600 ("v" "#+begin_verse\n?\n#+end_verse"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7601 "<verse>\n?\n/verse>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7602 ("l" "#+begin_latex\n?\n#+end_latex"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7603 "<literal style=\"latex\">\n?\n</literal>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7604 ("L" "#+latex: "
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7605 "<literal style=\"latex\">?</literal>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7606 ("h" "#+begin_html\n?\n#+end_html"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7607 "<literal style=\"html\">\n?\n</literal>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7608 ("H" "#+html: "
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7609 "<literal style=\"html\">?</literal>")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7610 ("a" "#+begin_ascii\n?\n#+end_ascii")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7611 ("A" "#+ascii: ")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7612 ("i" "#+include %file ?"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7613 "<include file=%file markup=\"?\">")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7614 )
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7615 "Structure completion elements.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7616 This is a list of abbreviation keys and values. The value gets inserted
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7617 it you type @samp{.} followed by the key and then the completion key,
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7618 usually `M-TAB'. %file will be replaced by a file name after prompting
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7619 for the file uning completion.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7620 There are two templates for each key, the first uses the original Org syntax,
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7621 the second uses Emacs Muse-like syntax tags. These Muse-like tags become
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7622 the default when the /org-mtags.el/ module has been loaded. See also the
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7623 variable `org-mtags-prefere-muse-templates'.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7624 This is an experimental feature, it is undecided if it is going to stay in."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7625 :group 'org-completion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7626 :type '(repeat
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7627 (string :tag "Key")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7628 (string :tag "Template")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7629 (string :tag "Muse Template")))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7630
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7631 (defun org-try-structure-completion ()
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7632 "Try to complete a structure template before point.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7633 This looks for strings like \"<e\" on an otherwise empty line and
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7634 expands them."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7635 (let ((l (buffer-substring (point-at-bol) (point)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7636 a)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7637 (when (and (looking-at "[ \t]*$")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7638 (string-match "^[ \t]*<\\([a-z]+\\)$"l)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7639 (setq a (assoc (match-string 1 l) org-structure-template-alist)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7640 (org-complete-expand-structure-template (+ -1 (point-at-bol)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7641 (match-beginning 1)) a)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7642 t)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7643
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7644 (defun org-complete-expand-structure-template (start cell)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7645 "Expand a structure template."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7646 (let* ((musep (org-bound-and-true-p org-mtags-prefere-muse-templates))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7647 (rpl (nth (if musep 2 1) cell)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7648 (delete-region start (point))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7649 (when (string-match "\\`#\\+" rpl)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7650 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7651 ((bolp))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7652 ((not (string-match "\\S-" (buffer-substring (point-at-bol) (point))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7653 (delete-region (point-at-bol) (point)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7654 (t (newline))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7655 (setq start (point))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7656 (if (string-match "%file" rpl)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7657 (setq rpl (replace-match
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7658 (concat
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7659 "\""
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7660 (save-match-data
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7661 (abbreviate-file-name (read-file-name "Include file: ")))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7662 "\"")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7663 t t rpl)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7664 (insert rpl)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7665 (if (re-search-backward "\\?" start t) (delete-char 1))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7666
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7667
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7668 (defun org-complete (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7669 "Perform completion on word at point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7670 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
7671 `org-todo-keywords'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7672 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
7673 that are supported for HTML support.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7674 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
7675 setting file options.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7676 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
7677 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
7678 `org-completion-fallback-command'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7679 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7680 (org-without-partial-completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7681 (catch 'exit
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7682 (let* ((a nil)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7683 (end (point))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7684 (beg1 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7685 (skip-chars-backward (org-re "[:alnum:]_@"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7686 (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7687 (beg (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7688 (skip-chars-backward "a-zA-Z0-9_:$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7689 (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7690 (confirm (lambda (x) (stringp (car x))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7691 (searchhead (equal (char-before beg) ?*))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7692 (struct
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7693 (when (and (member (char-before beg1) '(?. ?<))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7694 (setq a (assoc (buffer-substring beg1 (point))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7695 org-structure-template-alist)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7696 (org-complete-expand-structure-template (1- beg1) a)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
7697 (throw 'exit t)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7698 (tag (and (equal (char-before beg1) ?:)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7699 (equal (char-after (point-at-bol)) ?*)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7700 (prop (and (equal (char-before beg1) ?:)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7701 (not (equal (char-after (point-at-bol)) ?*))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7702 (texp (equal (char-before beg) ?\\))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7703 (link (equal (char-before beg) ?\[))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7704 (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
7705 beg)
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 (startup (string-match "^#\\+STARTUP:.*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7708 (buffer-substring (point-at-bol) (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7709 (completion-ignore-case opt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7710 (type nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7711 (tbl nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7712 (table (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7713 (opt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7714 (setq type :opt)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7715 (require 'org-exp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7716 (append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7717 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7718 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7719 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7720 (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
7721 (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
7722 (mapcar 'list org-additional-option-like-keywords)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7723 (startup
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7724 (setq type :startup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7725 org-startup-options)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7726 (link (append org-link-abbrev-alist-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7727 org-link-abbrev-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7728 (texp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7729 (setq type :tex)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7730 org-html-entities)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7731 ((string-match "\\`\\*+[ \t]+\\'"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7732 (buffer-substring (point-at-bol) beg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7733 (setq type :todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7734 (mapcar 'list org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7735 (searchhead
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7736 (setq type :searchhead)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7737 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7738 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7739 (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
7740 (push (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7741 (org-make-org-heading-search-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7742 (match-string 3) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7743 tbl)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7744 tbl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7745 (tag (setq type :tag beg beg1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7746 (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
7747 (prop (setq type :prop beg beg1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7748 (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
7749 (t (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7750 (call-interactively org-completion-fallback-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7751 (throw 'exit nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7752 (pattern (buffer-substring-no-properties beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7753 (completion (try-completion pattern table confirm)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7754 (cond ((eq completion t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7755 (if (not (assoc (upcase pattern) table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7756 (message "Already complete")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
7757 (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
7758 (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
7759 org-additional-option-like-keywords)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7760 (insert (substring (cdr (assoc (upcase pattern) table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7761 (length pattern)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7762 (if (memq type '(:tag :prop)) (insert ":")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7763 ((null completion)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7764 (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
7765 (ding))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7766 ((not (string= pattern completion))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7767 (delete-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7768 (if (string-match " +$" completion)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7769 (setq completion (replace-match "" t t completion)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7770 (insert completion)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7771 (if (get-buffer-window "*Completions*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7772 (delete-window (get-buffer-window "*Completions*")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7773 (if (assoc completion table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7774 (if (eq type :todo) (insert " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7775 (if (memq type '(:tag :prop)) (insert ":"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7776 (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
7777 (message "%s" (substitute-command-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7778 "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
7779 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7780 (message "Making completion list...")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7781 (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
7782 'string<)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7783 (with-output-to-temp-buffer "*Completions*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7784 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7785 ;; Protection needed for XEmacs and emacs 21
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7786 (display-completion-list list pattern)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7787 (error (display-completion-list list)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7788 (message "Making completion list...%s" "done")))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7789
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7790 ;;;; TODO, DEADLINE, Comments
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7791
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7792 (defun org-toggle-comment ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7793 "Change the COMMENT state of an entry."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7794 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7795 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7796 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7797 (let (case-fold-search)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7798 (if (looking-at (concat outline-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7799 "\\( *\\<" org-comment-string "\\>[ \t]*\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7800 (replace-match "" t t nil 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7801 (if (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7802 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7803 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7804 (insert org-comment-string " ")))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7805
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7806 (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
7807 "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
7808 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
7809 this is nil.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7810
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7811 (defvar org-setting-tags nil) ; dynamically skiped
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7812
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7813 (defun org-parse-local-options (string var)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7814 "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
7815 (let ((rtn (symbol-value var))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7816 e opts)
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 (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
7819 rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7820 (setq opts (delq nil (mapcar (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7821 (setq e (assoc x org-startup-options))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7822 (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
7823 (org-split-string string "[ \t]+"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7824 (if (not opts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7825 rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7826 (setq rtn nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7827 (while (setq e (pop opts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7828 (if (not (nth 3 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7829 (setq rtn (nth 2 e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7830 (if (not (listp rtn)) (setq rtn nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7831 (push (nth 2 e) rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7832 rtn)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7833
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7834 (defvar org-blocker-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7835 "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
7836
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7837 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
7838 `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
7839
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7840 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
7841 is blocked.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7842
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7843 (defvar org-trigger-hook nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7844 "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
7845
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7846 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
7847 the following elements:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7848
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7849 (: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
7850 :from old-state :to new-state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7851
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7852 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
7853
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7854 This mechanism is currently implemented for:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7855
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7856 TODO state changes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7857 ------------------
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7858 :type todo-state-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7859 :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
7860 :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
7861
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
7862 (defvar org-agenda-headline-snapshot-before-repeat)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7863 (defun org-todo (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7864 "Change the TODO state of an item.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7865 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
7866 like
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7867 *** TODO Write paper
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7868 *** DONE Call mom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7869
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7870 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
7871 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
7872 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
7873 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
7874 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
7875
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7876 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
7877 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
7878
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7879 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
7880 'none -> empty state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7881 \"\"(empty string) -> switch to empty state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7882 'done -> switch to DONE
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7883 '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
7884 '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
7885 \"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
7886 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
7887 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7888 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7889 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7890 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7891 (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
7892 (or (looking-at (concat " +" org-todo-regexp " *"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7893 (looking-at " *"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7894 (let* ((match-data (match-data))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7895 (startpos (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7896 (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
7897 (org-log-done org-log-done)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7898 (org-log-repeat org-log-repeat)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7899 (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
7900 (this (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7901 (hl-pos (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7902 (head (org-get-todo-sequence-head this))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7903 (ass (assoc head org-todo-kwd-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7904 (interpret (nth 1 ass))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7905 (done-word (nth 3 ass))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7906 (final-done-word (nth 4 ass))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7907 (last-state (or this ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7908 (completion-ignore-case t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7909 (member (member this org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7910 (tail (cdr member))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7911 (state (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7912 ((and org-todo-key-trigger
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7913 (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
7914 (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
7915 (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
7916 ;; Use fast selection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7917 (org-fast-todo-selection))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7918 ((and (equal arg '(4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7919 (or (not org-use-fast-todo-selection)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7920 (not org-todo-key-trigger)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7921 ;; Read a state with completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7922 (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
7923 org-todo-keywords-1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7924 nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7925 ((eq arg 'right)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7926 (if this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7927 (if tail (car tail) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7928 (car org-todo-keywords-1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7929 ((eq arg 'left)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7930 (if (equal member org-todo-keywords-1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7931 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7932 (if this
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7933 (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
7934 org-todo-keywords-1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7935 (org-last org-todo-keywords-1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7936 ((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
7937 (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
7938 (arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7939 ;; user or caller requests a specific state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7940 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7941 ((equal arg "") nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7942 ((eq arg 'none) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7943 ((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
7944 ((eq arg 'nextset)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7945 (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
7946 (car org-todo-heads)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7947 ((eq arg 'previousset)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7948 (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
7949 (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
7950 (car org-todo-heads))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7951 ((car (member arg org-todo-keywords-1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7952 ((nth (1- (prefix-numeric-value arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7953 org-todo-keywords-1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7954 ((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
7955 ((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
7956 ((null tail) nil) ;; -> first entry
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7957 ((eq interpret 'sequence)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7958 (car tail))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7959 ((memq interpret '(type priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7960 (if (eq this-command last-command)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7961 (car tail)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7962 (if (> (length tail) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7963 (or done-word (car org-done-keywords))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7964 nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7965 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7966 (next (if state (concat " " state " ") " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7967 (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
7968 :position startpos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7969 dolog now-done-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7970 (when org-blocker-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7971 (unless (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7972 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7973 (run-hook-with-args-until-failure
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7974 'org-blocker-hook change-plist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7975 (if (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7976 (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
7977 ;; fail silently
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7978 (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
7979 (throw 'exit nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7980 (store-match-data match-data)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7981 (replace-match next t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7982 (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
7983 (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
7984 (unless head
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7985 (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
7986 ass (assoc head org-todo-kwd-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7987 interpret (nth 1 ass)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7988 done-word (nth 3 ass)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7989 final-done-word (nth 4 ass)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7990 (when (memq arg '(nextset previousset))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7991 (message "Keyword-Set %d/%d: %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7992 (- (length org-todo-sets) -1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7993 (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
7994 (length org-todo-sets)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7995 (mapconcat 'identity (assoc state org-todo-sets) " ")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7996 (setq org-last-todo-state-is-todo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7997 (not (member state org-done-keywords)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7998 (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
7999 (not (member this org-done-keywords))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8000 (and logging (org-local-logging logging))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8001 (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
8002 (not (memq arg '(nextset previousset))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8003 ;; 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
8004 (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
8005 (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
8006 (when (and state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8007 (member state org-not-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8008 (not (member this org-not-done-keywords)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8009 ;; 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
8010 ;; 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
8011 (org-add-planning-info nil nil 'closed))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8012 (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
8013 ;; 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
8014 (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
8015 (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
8016 (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
8017 (when (and state dolog)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8018 ;; 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
8019 (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
8020 ;; Fixup tag positioning
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8021 (org-todo-trigger-tag-changes state)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8022 (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8023 (when org-provide-todo-statistics
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8024 (org-update-parent-todo-statistics))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8025 (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
8026 (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
8027 (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
8028 (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
8029 ;; Do we need to trigger a repeat?
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8030 (when now-done-p
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8031 (when (boundp 'org-agenda-headline-snapshot-before-repeat)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8032 ;; This is for the agenda, take a snapshot of the headline.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8033 (save-match-data
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8034 (setq org-agenda-headline-snapshot-before-repeat
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8035 (org-get-heading))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8036 (org-auto-repeat-maybe state))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8037 ;; 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
8038 (if (and (outline-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8039 (not (bolp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8040 (save-excursion (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8041 (looking-at org-todo-line-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8042 (< (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
8043 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8044 (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
8045 (just-one-space)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8046 (when org-trigger-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8047 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8048 (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
8049
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8050 (defun org-update-parent-todo-statistics ()
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8051 "Update any statistics cookie in the parent of the current headline."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8052 (interactive)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8053 (let ((box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8054 level (cnt-all 0) (cnt-done 0) is-percent kwd)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8055 (catch 'exit
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8056 (save-excursion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8057 (setq level (org-up-heading-safe))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8058 (unless (and level
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8059 (re-search-forward box-re (point-at-eol) t))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8060 (throw 'exit nil))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8061 (setq is-percent (match-end 2))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8062 (save-match-data
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8063 (unless (outline-next-heading) (throw 'exit nil))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8064 (while (looking-at org-todo-line-regexp)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8065 (setq kwd (match-string 2))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8066 (and kwd (setq cnt-all (1+ cnt-all)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8067 (and (member kwd org-done-keywords)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8068 (setq cnt-done (1+ cnt-done)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8069 (condition-case nil
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8070 (org-forward-same-level 1)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8071 (error (end-of-line 1)))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8072 (replace-match
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8073 (if is-percent
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8074 (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8075 (format "[%d/%d]" cnt-done cnt-all)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8076 (run-hook-with-args 'org-after-todo-statistics-hook
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8077 cnt-done (- cnt-all cnt-done))))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8078
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8079 (defvar org-after-todo-statistics-hook nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8080 "Hook that is called after a TODO statistics cookie has been updated.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8081 Each function is called with two arguments: the number of not-done entries
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8082 and the number of done entries.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8083
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8084 For example, the following function, when added to this hook, will switch
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8085 an entry to DONE when all children are done, and back to TODO when new
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8086 entries are set to a TODO status. Note that this hook is only called
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8087 when there is a statistics cookie in the headline!
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8088
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8089 (defun org-summary-todo (n-done n-not-done)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8090 \"Switch entry to DONE when all subentries are done, to TODO otherwise.\"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8091 (let (org-log-done org-log-states) ; turn off logging
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8092 (org-todo (if (= n-not-done 0) \"DONE\" \"TODO\"))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8093 ")
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8094
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8095 (defun org-todo-trigger-tag-changes (state)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8096 "Apply the changes defined in `org-todo-state-tags-triggers'."
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8097 (let ((l org-todo-state-tags-triggers)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8098 changes)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8099 (when (or (not state) (equal state ""))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8100 (setq changes (append changes (cdr (assoc "" l)))))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8101 (when (and (stringp state) (> (length state) 0))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8102 (setq changes (append changes (cdr (assoc state l)))))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8103 (when (member state org-not-done-keywords)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8104 (setq changes (append changes (cdr (assoc 'todo l)))))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8105 (when (member state org-done-keywords)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8106 (setq changes (append changes (cdr (assoc 'done l)))))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8107 (dolist (c changes)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8108 (org-toggle-tag (car c) (if (cdr c) 'on 'off)))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8109
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8110 (defun org-local-logging (value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8111 "Get logging settings from a property VALUE."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8112 (let* (words w a)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8113 ;; 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
8114 (setq org-log-done nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8115 org-log-repeat nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8116 org-todo-log-states nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8117 (setq words (org-split-string value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8118 (while (setq w (pop words))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8119 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8120 ((setq a (assoc w org-startup-options))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8121 (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
8122 (set (nth 1 a) (nth 2 a))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8123 ((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
8124 (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
8125 (push a org-todo-log-states)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8126
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8127 (defun org-get-todo-sequence-head (kwd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8128 "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
8129 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
8130 right sequence."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8131 (let (p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8132 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8133 ((not kwd)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8134 (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
8135 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8136 (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
8137 nil (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8138 (get-text-property p 'org-todo-head))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8139 ((not (member kwd org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8140 (car org-todo-keywords-1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8141 (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
8142
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8143 (defun org-fast-todo-selection ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8144 "Fast TODO keyword selection with single keys.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8145 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
8146 (let* ((fulltable org-todo-key-alist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8147 (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
8148 (maxlen (apply 'max (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8149 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8150 (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
8151 fulltable)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8152 (expert nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8153 (fwidth (+ maxlen 3 1 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8154 (ncol (/ (- (window-width) 4) fwidth))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8155 tg cnt e c tbl
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8156 groups ingroup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8157 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8158 (if expert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8159 (set-buffer (get-buffer-create " *Org todo*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8160 (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
8161 (erase-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8162 (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
8163 (setq tbl fulltable cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8164 (while (setq e (pop tbl))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8165 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8166 ((equal e '(:startgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8167 (push '() groups) (setq ingroup t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8168 (when (not (= cnt 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8169 (setq cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8170 (insert "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8171 (insert "{ "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8172 ((equal e '(:endgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8173 (setq ingroup nil cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8174 (insert "}\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8175 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8176 (setq tg (car e) c (cdr e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8177 (if ingroup (push tg (car groups)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8178 (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
8179 (org-get-todo-face tg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8180 (if (and (= cnt 0) (not ingroup)) (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8181 (insert "[" c "] " tg (make-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8182 (- fwidth 4 (length tg)) ?\ ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8183 (when (= (setq cnt (1+ cnt)) ncol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8184 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8185 (if ingroup (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8186 (setq cnt 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8187 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8188 (goto-char (point-min))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8189 (if (not expert) (org-fit-window-to-buffer))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8190 (message "[a-z..]:Set [SPC]:clear")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8191 (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
8192 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8193 ((or (= c ?\C-g)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8194 (and (= c ?q) (not (rassoc c fulltable))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8195 (setq quit-flag t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8196 ((= c ?\ ) nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8197 ((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
8198 tg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8199 (t (setq quit-flag t))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8200
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8201 (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
8202 (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
8203
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8204 (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
8205 (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
8206
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8207 (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
8208 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8209 (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
8210 (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
8211 (match-end 2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8212 (match-string 2))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8213
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8214 (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
8215 "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
8216 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8217 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8218 (catch 'exit
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8219 (let ((pos (point)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8220 (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
8221 (skip-chars-backward "<[")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8222 (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
8223 (>= (match-end 0) pos)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8224 (throw 'exit t))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8225 (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
8226 (skip-chars-backward "<[")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8227 (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
8228 (>= (match-end 0) pos)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8229 (throw 'exit t)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8230 nil)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8231
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8232 (defun org-get-repeat ()
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
8233 "Check if there is a deadline/schedule with repeater in this entry."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8234 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8235 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8236 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8237 (if (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8238 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
8239 (match-string 1)))))
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-last-changed-timestamp)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8242 (defvar org-last-inserted-timestamp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8243 (defvar org-log-post-message)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8244 (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
8245 (defvar org-log-note-how)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8246 (defvar org-log-note-extra)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8247 (defun org-auto-repeat-maybe (done-word)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8248 "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
8249 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
8250 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
8251 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
8252 ;; 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
8253 (let* ((repeat (org-get-repeat))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8254 (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
8255 (interpret (nth 1 aa))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8256 (head (nth 2 aa))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8257 (whata '(("d" . day) ("m" . month) ("y" . year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8258 (msg "Entry repeats: ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8259 (org-log-done nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8260 (org-todo-log-states nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8261 (nshiftmax 10) (nshift 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8262 re type n what ts mb0 time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8263 (when repeat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8264 (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
8265 (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
8266 (when org-log-repeat
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8267 (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
8268 (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
8269 ;; 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
8270 (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
8271 ;; 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
8272 (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
8273 ;; 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
8274 (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
8275 'findpos org-log-repeat)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8276 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8277 (org-add-planning-info nil nil 'closed)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8278 (setq re (concat "\\(" org-scheduled-time-regexp "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8279 org-deadline-time-regexp "\\)\\|\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8280 org-ts-regexp "\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8281 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8282 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
8283 (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
8284 (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
8285 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
8286 mb0 (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8287 (when (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8288 (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
8289 what (match-string 3 ts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8290 (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
8291 ;; 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
8292 (when (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8293 (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
8294 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8295 ((equal (match-string 1 ts) ".")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8296 ;; Shift starting date to today
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8297 (org-timestamp-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8298 (- (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
8299 'day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8300 ((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
8301 (while (or (= nshift 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8302 (<= (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
8303 (when (= (incf nshift) nshiftmax)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8304 (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
8305 (error "Abort")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8306 (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
8307 (org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8308 (setq ts (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8309 (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
8310 (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
8311 ;; 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
8312 (org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8313 (setq ts (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8314 (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8315 (org-timestamp-change n (cdr (assoc what whata)))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8316 (setq msg (concat msg type " " org-last-changed-timestamp " "))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8317 (setq org-log-post-message msg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8318 (message "%s" msg))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8319
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8320 (defun org-show-todo-tree (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8321 "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
8322 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
8323 headlines above the match.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8324 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
8325 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
8326 of `org-todo-keywords-1'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8327 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8328 (let ((case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8329 (kwd-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8330 (cond ((null arg) org-not-done-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8331 ((equal arg '(4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8332 (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
8333 (mapcar 'list org-todo-keywords-1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8334 (concat "\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8335 (mapconcat 'identity (org-split-string kwd "|") "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8336 "\\)\\>")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8337 ((<= (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
8338 (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
8339 org-todo-keywords-1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8340 (t (error "Invalid prefix argument: %s" arg)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8341 (message "%d TODO entries found"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8342 (org-occur (concat "^" outline-regexp " *" kwd-re )))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8343
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8344 (defun org-deadline (&optional remove time)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8345 "Insert the \"DEADLINE:\" string with a timestamp to make a deadline.
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8346 With argument REMOVE, remove any deadline from the item.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8347 When TIME is set, it should be an internal time specification, and the
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8348 scheduling will use the corresponding date."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8349 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8350 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8351 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8352 (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
8353 (message "Item no longer has a deadline."))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8354 (if (org-get-repeat)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8355 (error "Cannot change deadline on task with repeater, please do that by hand")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8356 (org-add-planning-info 'deadline time 'closed)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8357 (message "Deadline on %s" org-last-inserted-timestamp))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8358
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8359 (defun org-schedule (&optional remove time)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8360 "Insert the SCHEDULED: string with a timestamp to schedule a TODO item.
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8361 With argument REMOVE, remove any scheduling date from the item.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8362 When TIME is set, it should be an internal time specification, and the
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8363 scheduling will use the corresponding date."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8364 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8365 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8366 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8367 (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
8368 (message "Item is no longer scheduled."))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8369 (if (org-get-repeat)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8370 (error "Cannot reschedule task with repeater, please do that by hand")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8371 (org-add-planning-info 'scheduled time 'closed)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8372 (message "Scheduled to %s" org-last-inserted-timestamp))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8373
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8374 (defun org-remove-timestamp-with-keyword (keyword)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8375 "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
8376 (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
8377 beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8378 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8379 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8380 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8381 (org-end-of-subtree t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8382 (while (re-search-backward re beg t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8383 (replace-match "")
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8384 (if (and (string-match "\\S-" (buffer-substring (point-at-bol) (point)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8385 (equal (char-before) ?\ ))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8386 (backward-delete-char 1)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8387 (if (string-match "^[ \t]*$" (buffer-substring
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8388 (point-at-bol) (point-at-eol)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8389 (delete-region (point-at-bol)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8390 (min (point-max) (1+ (point-at-eol))))))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8391
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8392 (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
8393 "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
8394 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
8395 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
8396 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
8397 be removed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8398 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8399 (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
8400 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
8401
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8402 (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
8403 ;; 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
8404 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8405 (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
8406 (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
8407 (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
8408 org-scheduled-time-regexp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8409 org-deadline-time-regexp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8410 end t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8411 (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
8412 default-time
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8413 (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
8414 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
8415 (when what
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8416 ;; 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
8417 (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
8418 default-time default-input))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8419
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8420 (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
8421 (member what '(scheduled deadline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8422 (insert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8423 (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
8424 (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
8425 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
8426 (setq what nil))
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 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8429 (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
8430 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8431 (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8432 (goto-char (match-end 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8433 (setq col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8434 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8435 (if (eobp) (insert "\n") (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8436 (if (and (not (looking-at outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8437 (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
8438 "[^\r\n]*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8439 (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
8440 (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
8441 (insert-before-markers "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8442 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8443 (narrow-to-region (point) (point))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8444 (and org-adapt-indentation (org-indent-to-column col)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8445 ;; Check if we have to remove something.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8446 (setq list (cons what remove))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8447 (while list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8448 (setq elt (pop list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8449 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8450 (when (or (and (eq elt 'scheduled)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8451 (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
8452 (and (eq elt 'deadline)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8453 (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
8454 (and (eq elt 'closed)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8455 (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
8456 (replace-match "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8457 (if (looking-at "--+<[^>]+>") (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8458 (if (looking-at " +") (replace-match ""))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8459 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8460 (when what
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8461 (insert
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8462 (if (not (or (bolp) (eq (char-before) ?\ ))) " " "")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8463 (cond ((eq what 'scheduled) org-scheduled-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8464 ((eq what 'deadline) org-deadline-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8465 ((eq what 'closed) org-closed-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8466 " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8467 (setq ts (org-insert-time-stamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8468 time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8469 (or org-time-was-given
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8470 (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
8471 (eq what 'closed)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8472 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
8473 (end-of-line 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8474 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8475 (widen)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8476 (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
8477 (equal (char-before) ?\n))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8478 (delete-region (1- (point)) (point-at-eol)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8479 ts)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8480
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8481 (defvar org-log-note-marker (make-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8482 (defvar org-log-note-purpose nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8483 (defvar org-log-note-state nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8484 (defvar org-log-note-how nil)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8485 (defvar org-log-note-extra nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8486 (defvar org-log-note-window-configuration nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8487 (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
8488 (defvar org-log-post-message nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8489 "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
8490 The auto-repeater uses this.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8491
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8492 (defun org-add-note ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8493 "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
8494 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
8495 (interactive)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8496 (org-add-log-setup 'note nil 'findpos nil))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8497
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8498 (defvar org-property-end-re)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8499 (defun org-add-log-setup (&optional purpose state findpos how &optional extra)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8500 "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
8501 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
8502 When FINDPOS is non-nil, find the correct position for the note in
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8503 the current entry. If not, assume that it can be inserted at point.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8504 HOW is an indicator what kind of note should be created.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8505 EXTRA is additional text that will be inserted into the notes buffer."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8506 (save-restriction
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8507 (save-excursion
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8508 (when findpos
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8509 (org-back-to-heading t)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
8510 (narrow-to-region (point) (save-excursion
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8511 (outline-next-heading) (point)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8512 (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8513 "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8514 "[^\r\n]*\\)?"))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8515 (goto-char (match-end 0))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8516 (when (and org-log-state-notes-insert-after-drawers
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8517 (save-excursion
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8518 (forward-line) (looking-at org-drawer-regexp)))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8519 (progn (forward-line)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8520 (while (looking-at org-drawer-regexp)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8521 (goto-char (match-end 0))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8522 (re-search-forward org-property-end-re (point-max) t)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8523 (forward-line))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8524 (forward-line -1)))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8525 (unless org-log-states-order-reversed
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8526 (and (= (char-after) ?\n) (forward-char 1))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8527 (org-skip-over-state-notes)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8528 (skip-chars-backward " \t\n\r")))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8529 (move-marker org-log-note-marker (point))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8530 (setq org-log-note-purpose purpose
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8531 org-log-note-state state
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8532 org-log-note-how how
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8533 org-log-note-extra extra)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8534 (add-hook 'post-command-hook 'org-add-log-note 'append))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8535
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8536 (defun org-skip-over-state-notes ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8537 "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
8538 (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
8539 (while (looking-at "[ \t]*- State")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8540 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8541 (org-next-item)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8542 (error (org-end-of-item)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8543
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8544 (defun org-add-log-note (&optional purpose)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8545 "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
8546 (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
8547 (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
8548 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8549 (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
8550 (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
8551 (goto-char org-log-note-marker)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8552 (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
8553 (erase-buffer)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8554 (if (memq org-log-note-how '(time state))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
8555 (let (current-prefix-arg) (org-store-log-note))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8556 (let ((org-inhibit-startup t)) (org-mode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8557 (insert (format "# Insert note for %s.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8558 # 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
8559 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8560 ((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
8561 ((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
8562 ((eq org-log-note-purpose 'state)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8563 (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
8564 ((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
8565 "this entry")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8566 (t (error "This should not happen")))))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8567 (if org-log-note-extra (insert org-log-note-extra))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8568 (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
8569
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8570 (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
8571 (defun org-store-log-note ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8572 "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
8573 (let ((txt (buffer-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8574 (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
8575 lines ind)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8576 (kill-buffer (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8577 (while (string-match "\\`#.*\n[ \t\n]*" txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8578 (setq txt (replace-match "" t t txt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8579 (if (string-match "\\s-+\\'" txt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8580 (setq txt (replace-match "" t t txt)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8581 (setq lines (org-split-string txt "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8582 (when (and note (string-match "\\S-" note))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8583 (setq note
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8584 (org-replace-escapes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8585 note
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8586 (list (cons "%u" (user-login-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8587 (cons "%U" user-full-name)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8588 (cons "%t" (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8589 (org-time-stamp-format 'long 'inactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8590 (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8591 (cons "%s" (if org-log-note-state
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8592 (concat "\"" org-log-note-state "\"")
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 (if lines (setq note (concat note " \\\\")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8595 (push note lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8596 (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
8597 (when lines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8598 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8599 (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
8600 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8601 (goto-char org-log-note-marker)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8602 (move-marker org-log-note-marker nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8603 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8604 (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
8605 (indent-relative nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8606 (insert "- " (pop lines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8607 (org-indent-line-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8608 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8609 (looking-at "[ \t]*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8610 (setq ind (concat (match-string 0) " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8611 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8612 (while lines (insert "\n" ind (pop lines)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8613 (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
8614 (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
8615 (goto-char org-log-note-return-to))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8616 (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
8617 (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
8618
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8619 (defun org-sparse-tree (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8620 "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
8621 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
8622 of match used to create the tree:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8623
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8624 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
8625 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
8626 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
8627 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
8628 r Show entries matching a regular expression
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8629 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
8630 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8631 (let (ans kwd value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8632 (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
8633 (setq ans (read-char-exclusive))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8634 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8635 ((equal ans ?d)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8636 (call-interactively 'org-check-deadlines))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8637 ((equal ans ?b)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8638 (call-interactively 'org-check-before-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8639 ((equal ans ?t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8640 (org-show-todo-tree '(4)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8641 ((equal ans ?T)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8642 (call-interactively 'org-tags-sparse-tree))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8643 ((member ans '(?p ?P))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8644 (setq kwd (completing-read "Property: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8645 (mapcar 'list (org-buffer-property-keys))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8646 (setq value (completing-read "Value: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8647 (mapcar 'list (org-property-values kwd))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8648 (unless (string-match "\\`{.*}\\'" value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8649 (setq value (concat "\"" value "\"")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8650 (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
8651 ((member ans '(?r ?R ?/))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8652 (call-interactively 'org-occur))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8653 (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
8654
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8655 (defvar org-occur-highlights nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8656 "List of overlays used for occur matches.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8657 (make-variable-buffer-local 'org-occur-highlights)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8658 (defvar org-occur-parameters nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8659 "Parameters of the active org-occur calls.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8660 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
8661 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
8662 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
8663 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
8664 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
8665 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
8666 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
8667 as well.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8668 (make-variable-buffer-local 'org-occur-parameters)
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 (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
8671 "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
8672 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
8673 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
8674 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
8675 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
8676 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
8677 command.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8678 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
8679 that the match should indeed be shown."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8680 (interactive "sRegexp: \nP")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8681 (unless keep-previous
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8682 (org-remove-occur-highlights nil nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8683 (push (cons regexp callback) org-occur-parameters)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8684 (let ((cnt 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8685 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8686 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8687 (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
8688 (not org-occur-highlights)) ; no previous matches
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8689 ;; hide everything
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8690 (org-overview))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8691 (while (re-search-forward regexp nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8692 (when (or (not callback)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8693 (save-match-data (funcall callback)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8694 (setq cnt (1+ cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8695 (when org-highlight-sparse-tree-matches
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8696 (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
8697 (org-show-context 'occur-tree))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8698 (when org-remove-highlights-with-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8699 (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
8700 nil 'local))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8701 (unless org-sparse-tree-open-archived-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8702 (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
8703 (run-hooks 'org-occur-hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8704 (if (interactive-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8705 (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
8706 cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8707
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8708 (defun org-show-context (&optional key)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8709 "Make sure point and context and visible.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8710 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
8711 `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
8712 `org-show-siblings'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8713 (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
8714 (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
8715 (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
8716 (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
8717 (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
8718 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8719 ;; Show heading or entry text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8720 (if (and heading-p (not entry-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8721 (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
8722 (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
8723 (org-show-hidden-entry))) ; show entire entry
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8724 (when following-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8725 ;; Show next sibling, or heading below text
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8726 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8727 (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
8728 (org-flag-heading nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8729 (when siblings-p (org-show-siblings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8730 (when hierarchy-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8731 ;; show all higher headings, possibly with siblings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8732 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8733 (while (and (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8734 (progn (org-up-heading-all 1) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8735 (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8736 (not (bobp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8737 (org-flag-heading nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8738 (when siblings-p (org-show-siblings))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8739
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8740 (defun org-reveal (&optional siblings)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8741 "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
8742 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
8743 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
8744 not t for the search context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8745
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8746 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
8747 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
8748 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
8749 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8750 (let ((org-show-hierarchy-above t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8751 (org-show-following-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8752 (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
8753 (org-show-context nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8754
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8755 (defun org-highlight-new-match (beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8756 "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
8757 (let ((ov (org-make-overlay beg end)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8758 (org-overlay-put ov 'face 'secondary-selection)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8759 (push ov org-occur-highlights)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8760
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8761 (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
8762 "Remove the occur highlights from the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8763 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
8764 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
8765 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8766 (unless org-inhibit-highlight-removal
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8767 (mapc 'org-delete-overlay org-occur-highlights)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8768 (setq org-occur-highlights nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8769 (setq org-occur-parameters nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8770 (unless noremove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8771 (remove-hook 'before-change-functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8772 'org-remove-occur-highlights 'local))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8773
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8774 ;;;; Priorities
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8775
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8776 (defvar org-priority-regexp ".*?\\(\\[#\\([A-Z0-9]\\)\\] ?\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8777 "Regular expression matching the priority indicator.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8778
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8779 (defvar org-remove-priority-next-time nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8780
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8781 (defun org-priority-up ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8782 "Increase the priority of the current item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8783 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8784 (org-priority 'up))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8785
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8786 (defun org-priority-down ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8787 "Decrease the priority of the current item."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8788 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8789 (org-priority 'down))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8790
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8791 (defun org-priority (&optional action)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8792 "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
8793 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
8794 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8795 (setq action (or action 'set))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8796 (let (current new news have remove)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8797 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8798 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8799 (if (looking-at org-priority-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8800 (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
8801 have t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8802 (setq current org-default-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8803 (cond
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8804 ((or (eq action 'set)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8805 (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
8806 (if (not (eq action 'set))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8807 (setq new action)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8808 (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
8809 org-highest-priority org-lowest-priority)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8810 (setq new (read-char-exclusive)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8811 (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
8812 (= (upcase org-lowest-priority) org-lowest-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8813 (setq new (upcase new)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8814 (cond ((equal new ?\ ) (setq remove t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8815 ((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
8816 (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
8817 org-highest-priority org-lowest-priority))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8818 ((eq action 'up)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8819 (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
8820 (setq new org-lowest-priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8821 (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
8822 org-default-priority (1- current)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8823 ((eq action 'down)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8824 (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
8825 (setq new org-highest-priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8826 (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
8827 org-default-priority (1+ current)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8828 (t (error "Invalid action")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8829 (if (or (< (upcase new) org-highest-priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8830 (> (upcase new) org-lowest-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8831 (setq remove t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8832 (setq news (format "%c" new))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8833 (if have
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8834 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8835 (replace-match "" t t nil 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8836 (replace-match news t t nil 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8837 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8838 (error "No priority cookie found in line")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8839 (looking-at org-todo-line-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8840 (if (match-end 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8841 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8842 (goto-char (match-end 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8843 (insert " [#" news "]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8844 (goto-char (match-beginning 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8845 (insert "[#" news "] ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8846 (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
8847 (if remove
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8848 (message "Priority removed")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8849 (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
8850
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8851
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8852 (defun org-get-priority (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8853 "Find priority cookie and return priority."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8854 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8855 (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
8856 (* 1000 (- org-lowest-priority org-default-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8857 (* 1000 (- org-lowest-priority
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8858 (string-to-char (match-string 2 s)))))))
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 ;;;; Tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8861
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
8862 (defvar org-agenda-archives-mode)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8863 (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
8864 "Scan headline tags with inheritance and produce output ACTION.
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8865
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8866 ACTION can be `sparse-tree' to produce a sparse tree in the current buffer,
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8867 or `agenda' to produce an entry list for an agenda view. It can also be
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8868 a Lisp form or a function that should be called at each matched headline, in
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8869 this case the return value is a list of all return values from these calls.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8870
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8871 MATCHER is a Lisp form to be evaluated, testing if a given set of tags
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8872 qualifies a headline for inclusion. When TODO-ONLY is non-nil,
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8873 only lines with a TODO keyword are included in the output."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8874 (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8875 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8876 (org-re
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8877 "\\>\\)\\)? *\\(.*?\\)\\(:[[:alnum:]_@:]+:\\)?[ \t]*$")))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
8878 (props (list 'face 'default
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8879 'done-face 'org-done
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
8880 'undone-face 'default
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8881 'mouse-face 'highlight
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8882 '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
8883 'org-todo-regexp org-todo-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8884 'keymap org-agenda-keymap
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8885 'help-echo
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8886 (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
8887 (abbreviate-file-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8888 (or (buffer-file-name (buffer-base-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8889 (buffer-name (buffer-base-buffer)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8890 (case-fold-search nil)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8891 lspos tags tags-list
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8892 (tags-alist (list (cons 0 (mapcar 'downcase org-file-tags))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8893 (llast 0) rtn rtn1 level category i txt
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8894 todo marker entry priority)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8895 (when (not (or (member action '(agenda sparse-tree)) (functionp action)))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8896 (setq action (list 'lambda nil action)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8897 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8898 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8899 (when (eq action 'sparse-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8900 (org-overview)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8901 (org-remove-occur-highlights))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8902 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8903 (catch :skip
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8904 (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
8905 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
8906 (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
8907 (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
8908 category (org-get-category))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8909 (setq i llast llast level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8910 ;; remove tag lists from same and sublevels
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8911 (while (>= i level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8912 (when (setq entry (assoc i tags-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8913 (setq tags-alist (delete entry tags-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8914 (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
8915 ;; add the next tags
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8916 (when tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8917 (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
8918 tags-alist
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8919 (cons (cons level tags) tags-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8920 ;; compile tags for current headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8921 (setq tags-list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8922 (if org-use-tag-inheritance
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8923 (apply 'append (mapcar 'cdr tags-alist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8924 tags))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8925 (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
8926 (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
8927 ;; 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
8928 (setcdr (car tags-alist)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8929 (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
8930 (when (and (or (not todo-only) (member todo org-not-done-keywords))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8931 (let ((case-fold-search t)) (eval matcher))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
8932 (or
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
8933 (not (member org-archive-tag tags-list))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
8934 ;; we have an archive tag, should we use this anyway?
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
8935 (or (not org-agenda-skip-archived-trees)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
8936 (and (eq action 'agenda) org-agenda-archives-mode))))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8937 (unless (eq action 'sparse-tree) (org-agenda-skip))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8938
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8939 ;; select this headline
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8940
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8941 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8942 ((eq action 'sparse-tree)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8943 (and org-highlight-sparse-tree-matches
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8944 (org-get-heading) (match-end 0)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8945 (org-highlight-new-match
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8946 (match-beginning 0) (match-beginning 1)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8947 (org-show-context 'tags-tree))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8948 ((eq action 'agenda)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8949 (setq txt (org-format-agenda-item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8950 ""
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8951 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8952 (if org-tags-match-list-sublevels
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8953 (make-string (1- level) ?.) "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8954 (org-get-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8955 category tags-list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8956 priority (org-get-priority txt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8957 (goto-char lspos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8958 (setq marker (org-agenda-new-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8959 (org-add-props txt props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8960 '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
8961 'priority priority 'type "tagsmatch")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8962 (push txt rtn))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8963 ((functionp action)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8964 (save-excursion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8965 (setq rtn1 (funcall action))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8966 (push rtn1 rtn))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8967 (goto-char (point-at-eol)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8968 (t (error "Invalid action")))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
8969
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8970 ;; 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
8971 (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
8972 (when (and (eq action 'sparse-tree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8973 (not org-sparse-tree-open-archived-trees))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8974 (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
8975 (nreverse rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8976
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8977 (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
8978 "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
8979 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8980 ((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
8981 ((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
8982 ((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
8983 (delq nil (mapcar
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8984 (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
8985 tags)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8986 ((listp org-use-tag-inheritance)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8987 (delq nil (mapcar
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8988 (lambda (x) (if (member x org-use-tag-inheritance) x nil))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
8989 tags)))))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
8990
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8991 (defvar todo-only) ;; dynamically scoped
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8992
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8993 (defun org-tags-sparse-tree (&optional todo-only match)
99655
700e59a3b82f * emulation/viper-cmd.el (viper-harness-minor-mode): Fix docstring typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 99514
diff changeset
8994 "Create a sparse tree according to tags string MATCH.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8995 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
8996 \"+WORK+URGENT-WITHBOSS\".
99655
700e59a3b82f * emulation/viper-cmd.el (viper-harness-minor-mode): Fix docstring typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 99514
diff changeset
8997 If optional argument TODO-ONLY is non-nil, only select lines that are
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8998 also TODO lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8999 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9000 (org-prepare-agenda-buffers (list (current-buffer)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9001 (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
9002
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9003 (defvar org-cached-props nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9004 (defun org-cached-entry-get (pom property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9005 (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
9006 (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
9007 (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
9008 (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
9009 (member property org-use-property-inheritance)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9010 ;; Caching is not possible, check it directly
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9011 (org-entry-get pom property 'inherit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9012 ;; 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
9013 (cdr (assoc property (or org-cached-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9014 (setq org-cached-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9015 (org-entry-properties pom)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9016
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9017 (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
9018 "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
9019 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9020 (org-uniquify
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9021 (delq nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9022 (apply 'append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9023 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9024 (lambda (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9025 (set-buffer (find-file-noselect file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9026 (append (org-get-buffer-tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9027 (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
9028 (list (car-safe x)) nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9029 org-tag-alist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9030 (if (and files (car files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9031 files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9032 (org-agenda-files))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9033
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9034 (defun org-make-tags-matcher (match)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9035 "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
9036 ;; 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
9037 ;; 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
9038 (unless match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9039 ;; Get a new match request, with completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9040 (let ((org-last-tags-completion-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9041 (org-global-tags-completion-table)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9042 (setq match (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9043 "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
9044 'org-tags-history))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9045
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9046 ;; 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
9047 (let ((match0 match)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9048 (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
9049 minus tag mm
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9050 tagsmatch todomatch tagsmatcher todomatcher kwd matcher
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9051 orterms term orlist re-p str-p level-p level-op time-p
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9052 prop-p pn pv po cat-p gv rest)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9053 (if (string-match "/+" match)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9054 ;; match contains also a todo-matching request
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9055 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9056 (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
9057 todomatch (substring match (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9058 (if (string-match "^!" todomatch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9059 (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
9060 (if (string-match "^\\s-*$" todomatch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9061 (setq todomatch nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9062 ;; only matching tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9063 (setq tagsmatch match todomatch nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9064
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9065 ;; Make the tags matcher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9066 (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
9067 (setq tagsmatcher t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9068 (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
9069 (while (setq term (pop orterms))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9070 (while (and (equal (substring term -1) "\\") orterms)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9071 (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
9072 (while (string-match re term)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9073 (setq rest (substring term (match-end 0))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9074 minus (and (match-end 1)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9075 (equal (match-string 1 term) "-"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9076 tag (match-string 2 term)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9077 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
9078 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
9079 prop-p (match-end 5)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9080 mm (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9081 (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
9082 (level-p
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9083 (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
9084 `(,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
9085 (match-string 4 term))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9086 (prop-p
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9087 (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
9088 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
9089 pv (match-string 7 term)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9090 cat-p (equal pn "CATEGORY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9091 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
9092 str-p (equal (string-to-char pv) ?\")
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9093 time-p (save-match-data
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9094 (string-match "^\"[[<].*[]>]\"$" pv))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9095 pv (if (or re-p str-p) (substring pv 1 -1) pv))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9096 (if time-p (setq pv (org-matcher-time pv)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9097 (setq po (org-op-to-function po (if time-p 'time str-p)))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9098 (cond
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9099 ((equal pn "CATEGORY")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9100 (setq gv '(get-text-property (point) 'org-category)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9101 ((equal pn "TODO")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9102 (setq gv 'todo))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9103 (t
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9104 (setq gv `(org-cached-entry-get nil ,pn))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9105 (if re-p
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9106 (if (eq po 'org<>)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9107 `(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
9108 `(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
9109 (if str-p
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9110 `(,po (or ,gv "") ,pv)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9111 `(,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
9112 ,(string-to-number pv) ))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9113 (t `(member ,(downcase tag) tags-list)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9114 mm (if minus (list 'not mm) mm)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9115 term rest)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9116 (push mm tagsmatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9117 (push (if (> (length tagsmatcher) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9118 (cons 'and tagsmatcher)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9119 (car tagsmatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9120 orlist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9121 (setq tagsmatcher nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9122 (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
9123 (setq tagsmatcher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9124 (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
9125 ;; Make the todo matcher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9126 (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
9127 (setq todomatcher t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9128 (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
9129 (while (setq term (pop orterms))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9130 (while (string-match re term)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9131 (setq minus (and (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9132 (equal (match-string 1 term) "-"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9133 kwd (match-string 2 term)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9134 re-p (equal (string-to-char kwd) ?{)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9135 term (substring term (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9136 mm (if re-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9137 `(string-match ,(substring kwd 1 -1) todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9138 (list 'equal 'todo kwd))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9139 mm (if minus (list 'not mm) mm))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9140 (push mm todomatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9141 (push (if (> (length todomatcher) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9142 (cons 'and todomatcher)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9143 (car todomatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9144 orlist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9145 (setq todomatcher nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9146 (setq todomatcher (if (> (length orlist) 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9147 (cons 'or orlist) (car orlist))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9148
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9149 ;; 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
9150 (setq matcher (if todomatcher
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9151 (list 'and tagsmatcher todomatcher)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9152 tagsmatcher))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9153 (cons match0 matcher)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9154
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9155 (defun org-op-to-function (op &optional stringp)
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9156 "Turn an operator into the appropriate function."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9157 (setq op
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9158 (cond
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9159 ((equal op "<" ) '(< string< org-time<))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9160 ((equal op ">" ) '(> org-string> org-time>))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9161 ((member op '("<=" "=<")) '(<= org-string<= org-time<=))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9162 ((member op '(">=" "=>")) '(>= org-string>= org-time>=))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9163 ((member op '("=" "==")) '(= string= org-time=))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9164 ((member op '("<>" "!=")) '(org<> org-string<> org-time<>))))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9165 (nth (if (eq stringp 'time) 2 (if stringp 1 0)) op))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9166
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9167 (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
9168 (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
9169 (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
9170 (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
9171 (defun org-string<> (a b) (not (string= a b)))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9172 (defun org-time= (a b) (= (org-2ft a) (org-2ft b)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9173 (defun org-time< (a b) (< (org-2ft a) (org-2ft b)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9174 (defun org-time<= (a b) (<= (org-2ft a) (org-2ft b)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9175 (defun org-time> (a b) (> (org-2ft a) (org-2ft b)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9176 (defun org-time>= (a b) (>= (org-2ft a) (org-2ft b)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9177 (defun org-time<> (a b) (org<> (org-2ft a) (org-2ft b)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9178 (defun org-2ft (s)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9179 "Convert S to a floating point time.
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9180 If S is already a number, just return it. If it is a string, parse
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9181 it as a time string and apply `float-time' to it. f S is nil, just return 0."
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9182 (cond
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9183 ((numberp s) s)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9184 ((stringp s)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9185 (condition-case nil
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9186 (float-time (apply 'encode-time (org-parse-time-string s)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9187 (error 0.)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9188 (t 0.)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9189
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9190 (defun org-matcher-time (s)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9191 (cond
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9192 ((equal s "<now>") (float-time))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9193 ((equal s "<today>")
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9194 (float-time (append '(0 0 0) (nthcdr 3 (decode-time)))))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9195 (t (org-2ft s))))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9196
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9197 (defun org-match-any-p (re list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9198 "Does re match any element of list?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9199 (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
9200 (delq nil list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9201
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9202 (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
9203 (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
9204 (org-detach-overlay org-tags-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9205
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9206 (defun org-get-local-tags-at (&optional pos)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9207 "Get a list of tags defined in the current headline."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9208 (org-get-tags-at pos 'local))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9209
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9210 (defun org-get-local-tags ()
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9211 "Get a list of tags defined in the current headline."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9212 (org-get-tags-at nil 'local))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9213
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9214 (defun org-get-tags-at (&optional pos local)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9215 "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
9216 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
9217 the targets in the same sequence as the headlines appear, i.e.
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9218 the tags of the current headline come last.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9219 When LOCAL is non-nil, only return tags from the current headline,
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9220 ignore inherited ones."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9221 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9222 (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
9223 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9224 (save-restriction
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9225 (widen)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9226 (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
9227 (save-match-data
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9228 (catch 'done
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9229 (condition-case nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9230 (progn
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9231 (org-back-to-heading t)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9232 (while (not (equal lastpos (point)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9233 (setq lastpos (point))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9234 (when (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$"))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9235 (setq ltags (org-split-string
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9236 (org-match-string-no-properties 1) ":"))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9237 (setq tags (append
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9238 (if parent
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9239 (org-remove-uniherited-tags ltags)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9240 ltags)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9241 tags)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9242 (or org-use-tag-inheritance (throw 'done t))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9243 (if local (throw 'done t))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9244 (org-up-heading-all 1)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9245 (setq parent t)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9246 (error nil)))))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9247 (append (org-remove-uniherited-tags org-file-tags) tags))))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9248
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9249 (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
9250 "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
9251 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
9252 (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
9253 (let (res current)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9254 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9255 (beginning-of-line)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9256 (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
9257 (point-at-eol) t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9258 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9259 (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
9260 (replace-match ""))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9261 (setq current ""))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9262 (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
9263 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9264 ((eq onoff 'on)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9265 (setq res t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9266 (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
9267 ((eq onoff 'off)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9268 (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
9269 (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
9270 (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
9271 (setq res t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9272 (push tag current))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9273 (end-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9274 (if current
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9275 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9276 (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
9277 (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
9278 (delete-horizontal-space))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9279 (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
9280 res))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9281
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9282 (defun org-align-tags-here (to-col)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9283 ;; 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
9284 (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
9285 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9286 (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
9287 (< pos (match-beginning 2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9288 (progn
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9289 (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
9290 (goto-char (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9291 (insert " ")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9292 (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
9293 (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
9294 (1+ col)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9295 (if (> to-col 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9296 to-col
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9297 (- (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
9298 (setq p (point))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9299 (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
9300 (setq ncol (current-column))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9301 (when indent-tabs-mode (tabify p (point-at-eol)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9302 (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
9303 (goto-char pos))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9304
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9305 (defun org-set-tags-command (&optional arg just-align)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9306 "Call the set-tags command for the current entry."
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9307 (interactive "P")
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9308 (if (org-on-heading-p)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9309 (org-set-tags arg just-align)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9310 (save-excursion
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9311 (org-back-to-heading t)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9312 (org-set-tags arg just-align))))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9313
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9314 (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
9315 "Set the tags for the current headline.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9316 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
9317 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9318 (let* ((re (concat "^" outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9319 (current (org-get-tags-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9320 (col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9321 (org-setting-tags t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9322 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
9323 tags p0 c0 c1 rpl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9324 (if arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9325 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9326 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9327 (let ((buffer-invisibility-spec (org-inhibit-invisibility)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9328 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9329 (org-set-tags nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9330 (end-of-line 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9331 (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
9332 (if just-align
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9333 (setq tags current)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9334 ;; 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
9335 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9336 (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
9337 org-last-tags-completion-table table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9338 current-tags (org-split-string current ":")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9339 inherited-tags (nreverse
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9340 (nthcdr (length current-tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9341 (nreverse (org-get-tags-at))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9342 tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9343 (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
9344 (and org-use-fast-tag-selection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9345 (delq nil (mapcar 'cdr table))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9346 (org-fast-tag-selection
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9347 current-tags inherited-tags table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9348 (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
9349 (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
9350 (org-trim
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9351 (org-without-partial-completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9352 (completing-read "Tags: " 'org-tags-completion-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9353 nil nil current 'org-tags-history)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9354 (while (string-match "[-+&]+" tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9355 ;; No boolean logic, just a list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9356 (setq tags (replace-match ":" t t tags))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9357
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9358 (if (string-match "\\`[\t ]*\\'" tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9359 (setq tags "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9360 (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
9361 (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
9362
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9363 ;; Insert new tags at the correct column
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9364 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9365 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9366 ((and (equal current "") (equal tags "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9367 ((re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9368 (concat "\\([ \t]*" (regexp-quote current) "\\)[ \t]*$")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9369 (point-at-eol) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9370 (if (equal tags "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9371 (setq rpl "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9372 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9373 (setq c0 (current-column) p0 (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9374 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
9375 org-tags-column
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9376 (- (- org-tags-column) (length tags))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9377 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
9378 (replace-match rpl t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9379 (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
9380 tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9381 (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
9382 (org-move-to-column col)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9383 (unless just-align
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9384 (run-hooks 'org-after-tags-change-hook)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9385
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9386 (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
9387 "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
9388 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
9389 (interactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9390 (list (region-beginning) (region-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9391 (let ((org-last-tags-completion-table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9392 (if (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9393 (org-get-buffer-tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9394 (org-global-tags-completion-table))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9395 (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9396 "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
9397 'org-tags-history))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9398 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9399 (message "[s]et or [r]emove? ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9400 (equal (read-char-exclusive) ?r))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9401 (if (fboundp 'deactivate-mark) (deactivate-mark))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9402 (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
9403 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
9404 (goto-char end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9405 (setq l2 (1- (org-current-line)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9406 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9407 (setq l1 (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9408 (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
9409 (goto-line l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9410 (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
9411 (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
9412 (and agendap m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9413 (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
9414 pos (if agendap m (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9415 (with-current-buffer buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9416 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9417 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9418 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9419 (setq cnt (1+ cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9420 (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
9421 (setq newhead (org-get-heading)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9422 (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
9423 (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
9424
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9425 (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
9426 (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
9427 (confirm (lambda (x) (stringp (car x)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9428 (if (string-match "^\\(.*[-+:&|]\\)\\([^-+:&|]*\\)$" string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9429 (setq s1 (match-string 1 string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9430 s2 (match-string 2 string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9431 (setq s1 "" s2 string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9432 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9433 ((eq flag nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9434 ;; try completion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9435 (setq rtn (try-completion s2 ctable confirm))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9436 (if (stringp rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9437 (setq rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9438 (concat s1 s2 (substring rtn (length s2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9439 (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
9440 (assoc rtn ctable))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9441 ":" ""))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9442 rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9443 ((eq flag t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9444 ;; all-completions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9445 (all-completions s2 ctable confirm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9446 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9447 ((eq flag 'lambda)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9448 ;; exact match?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9449 (assoc s2 ctable)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9450 ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9451
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9452 (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
9453 "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
9454 (insert (format "%-12s" (concat kwd ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9455 (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
9456 (or end "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9457
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9458 (defun org-fast-tag-show-exit (flag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9459 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9460 (goto-line 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9461 (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
9462 (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9463 (when flag
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9464 (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
9465 (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
9466 (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
9467
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9468 (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
9469 (let ((s (concat ":" (mapconcat 'identity current ":") ":")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9470 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9471 (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
9472 'secondary-selection)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9473 (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
9474 (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
9475
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9476 (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
9477 "Fast tag selection with single keys.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9478 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
9479 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
9480 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
9481 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
9482 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
9483 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
9484 (let* ((fulltable (append table todo-table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9485 (maxlen (apply 'max (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9486 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9487 (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
9488 fulltable)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9489 (buf (current-buffer))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9490 (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
9491 (buffer-tags nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9492 (fwidth (+ maxlen 3 1 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9493 (ncol (/ (- (window-width) 4) fwidth))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9494 (i-face 'org-done)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9495 (c-face 'org-todo)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9496 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
9497 ov-start ov-end ov-prefix
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9498 (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
9499 (done-keywords org-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9500 groups ingroup)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9501 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9502 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9503 (if (looking-at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9504 (org-re ".*[ \t]\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9505 (setq ov-start (match-beginning 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9506 ov-end (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9507 ov-prefix "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9508 (setq ov-start (1- (point-at-eol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9509 ov-end (1+ ov-start))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9510 (skip-chars-forward "^\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9511 (setq ov-prefix
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9512 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9513 (buffer-substring (1- (point)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9514 (if (> (current-column) org-tags-column)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9515 " "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9516 (make-string (- org-tags-column (current-column)) ?\ ))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9517 (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
9518 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9519 (if expert
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9520 (set-buffer (get-buffer-create " *Org tags*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9521 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9522 (split-window-vertically)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9523 (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
9524 (erase-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9525 (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
9526 (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
9527 (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
9528 (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
9529 (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
9530 (setq tbl fulltable char ?a cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9531 (while (setq e (pop tbl))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9532 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9533 ((equal e '(:startgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9534 (push '() groups) (setq ingroup t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9535 (when (not (= cnt 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9536 (setq cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9537 (insert "\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9538 (insert "{ "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9539 ((equal e '(:endgroup))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9540 (setq ingroup nil cnt 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9541 (insert "}\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9542 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9543 (setq tg (car e) c2 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9544 (if (cdr e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9545 (setq c (cdr e))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9546 ;; automatically assign a character.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9547 (setq c1 (string-to-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9548 (downcase (substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9549 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
9550 (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
9551 (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
9552 (setq char (1+ char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9553 (setq c2 c1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9554 (setq c (or c2 char)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9555 (if ingroup (push tg (car groups)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9556 (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
9557 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9558 ((not (assoc tg table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9559 (org-get-todo-face tg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9560 ((member tg current) c-face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9561 ((member tg inherited) i-face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9562 (t nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9563 (if (and (= cnt 0) (not ingroup)) (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9564 (insert "[" c "] " tg (make-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9565 (- fwidth 4 (length tg)) ?\ ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9566 (push (cons tg c) ntable)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9567 (when (= (setq cnt (1+ cnt)) ncol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9568 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9569 (if ingroup (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9570 (setq cnt 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9571 (setq ntable (nreverse ntable))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9572 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9573 (goto-char (point-min))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9574 (if (not expert) (org-fit-window-to-buffer))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9575 (setq rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9576 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9577 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9578 (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
9579 (if groups " [!] no groups" " [!]groups")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9580 (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
9581 (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
9582 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9583 ((= c ?\r) (throw 'exit t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9584 ((= c ?!)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9585 (setq groups (not groups))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9586 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9587 (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
9588 ((= c ?\C-c)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9589 (if (not expert)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9590 (org-fast-tag-show-exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9591 (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
9592 (setq expert nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9593 (delete-other-windows)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9594 (split-window-vertically)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9595 (org-switch-to-buffer-other-window " *Org tags*")
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9596 (org-fit-window-to-buffer)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9597 ((or (= c ?\C-g)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9598 (and (= c ?q) (not (rassoc c ntable))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9599 (org-detach-overlay org-tags-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9600 (setq quit-flag t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9601 ((= c ?\ )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9602 (setq current nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9603 (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
9604 ((= c ?\t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9605 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9606 (setq tg (completing-read
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9607 "Tag: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9608 (or buffer-tags
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9609 (with-current-buffer buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9610 (org-get-buffer-tags)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9611 (quit (setq tg "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9612 (when (string-match "\\S-" tg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9613 (add-to-list 'buffer-tags (list tg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9614 (if (member tg current)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9615 (setq current (delete tg current))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9616 (push tg current)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9617 (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
9618 ((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
9619 (with-current-buffer buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9620 (save-excursion (org-todo tg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9621 (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
9622 ((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
9623 (if (member tg current)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9624 (setq current (delete tg current))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9625 (loop for g in groups do
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9626 (if (member tg g)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9627 (mapc (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9628 (setq current (delete x current)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9629 g)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9630 (push tg current))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9631 (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
9632
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9633 ;; Create a sorted list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9634 (setq current
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9635 (sort current
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9636 (lambda (a b)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9637 (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
9638 (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
9639 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9640 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9641 (delete-region (point) (point-at-eol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9642 (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
9643 (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
9644 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9645 (org-re "\\[.\\] \\([[:alnum:]_@]+\\)") nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9646 (setq tg (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9647 (add-text-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9648 (match-beginning 1) (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9649 (list 'face
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9650 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9651 ((member tg current) c-face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9652 ((member tg inherited) i-face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9653 (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
9654 (goto-char (point-min)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9655 (org-detach-overlay org-tags-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9656 (if rtn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9657 (mapconcat 'identity current ":")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9658 nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9659
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9660 (defun org-get-tags-string ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9661 "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
9662 (unless (org-on-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9663 (error "Not on a heading"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9664 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9665 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9666 (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
9667 (org-match-string-no-properties 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9668 "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9669
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9670 (defun org-get-tags ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9671 "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
9672 (org-split-string (org-get-tags-string) ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9673
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9674 (defun org-get-buffer-tags ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9675 "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
9676 (let (tags)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9677 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9678 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9679 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9680 (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
9681 (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
9682 (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
9683 (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
9684 (mapcar 'list tags)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9685
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9686 ;;;; The mapping API
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9687
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9688 ;;;###autoload
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9689 (defun org-map-entries (func &optional match scope &rest skip)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9690 "Call FUNC at each headline selected by MATCH in SCOPE.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9691
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9692 FUNC is a function or a lisp form. The function will be called without
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9693 arguments, with the cursor positioned at the beginning of the headline.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9694 The return values of all calls to the function will be collected and
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9695 returned as a list.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9696
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9697 MATCH is a tags/property/todo match as it is used in the agenda tags view.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9698 Only headlines that are matched by this query will be considered during
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9699 the iteration. When MATCH is nil or t, all headlines will be
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9700 visited by the iteration.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9701
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9702 SCOPE determines the scope of this command. It can be any of:
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9703
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9704 nil The current buffer, respecting the restriction if any
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9705 tree The subtree started with the entry at point
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9706 file The current buffer, without restriction
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9707 file-with-archives
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9708 The current buffer, and any archives associated with it
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9709 agenda All agenda files
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9710 agenda-with-archives
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9711 All agenda files with any archive files associated with them
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9712 \(file1 file2 ...)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9713 If this is a list, all files in the list will be scanned
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9714
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9715 The remaining args are treated as settings for the skipping facilities of
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9716 the scanner. The following items can be given here:
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9717
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9718 archive skip trees with the archive tag.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9719 comment skip trees with the COMMENT keyword
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9720 function or Emacs Lisp form:
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9721 will be used as value for `org-agenda-skip-function', so whenever
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9722 the the function returns t, FUNC will not be called for that
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9723 entry and search will continue from the point where the
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9724 function leaves it."
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9725 (let* ((org-agenda-archives-mode nil) ; just to make sure
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9726 (org-agenda-skip-archived-trees (memq 'archive skip))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9727 (org-agenda-skip-comment-trees (memq 'comment skip))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9728 (org-agenda-skip-function
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9729 (car (org-delete-all '(comment archive) skip)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9730 (org-tags-match-list-sublevels t)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9731 matcher pos file
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9732 org-todo-keywords-for-agenda
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9733 org-done-keywords-for-agenda
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9734 org-todo-keyword-alist-for-agenda
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
9735 org-tag-alist-for-agenda)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9736
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9737 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9738 ((eq match t) (setq matcher t))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9739 ((eq match nil) (setq matcher t))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9740 (t (setq matcher (if match (org-make-tags-matcher match) t))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9741
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9742 (when (eq scope 'tree)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9743 (org-back-to-heading t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9744 (org-narrow-to-subtree)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9745 (setq scope nil))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9746
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9747 (if (not scope)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9748 (progn
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9749 (org-prepare-agenda-buffers
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9750 (list (buffer-file-name (current-buffer))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9751 (org-scan-tags func matcher))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9752 ;; Get the right scope
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9753 (setq pos (point))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9754 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9755 ((and scope (listp scope) (symbolp (car scope)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9756 (setq scope (eval scope)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9757 ((eq scope 'agenda)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9758 (setq scope (org-agenda-files t)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9759 ((eq scope 'agenda-with-archives)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9760 (setq scope (org-agenda-files t))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9761 (setq scope (org-add-archive-files scope)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9762 ((eq scope 'file)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9763 (setq scope (list (buffer-file-name))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9764 ((eq scope 'file-with-archives)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9765 (setq scope (org-add-archive-files (list (buffer-file-name))))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9766 (org-prepare-agenda-buffers scope)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9767 (while (setq file (pop scope))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9768 (with-current-buffer (org-find-base-buffer-visiting file)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9769 (save-excursion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9770 (save-restriction
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9771 (widen)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9772 (goto-char (point-min))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9773 (org-scan-tags func matcher))))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9774
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9775 ;;;; Properties
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 ;;; Setting and retrieving properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9778
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9779 (defconst org-special-properties
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9780 '("TODO" "TAGS" "ALLTAGS" "DEADLINE" "SCHEDULED" "CLOCK" "CLOSED" "PRIORITY"
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9781 "TIMESTAMP" "TIMESTAMP_IA")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9782 "The special properties valid in Org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9783
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9784 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
9785 but in some other way.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9786
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9787 (defconst org-default-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9788 '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION"
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9789 "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9790 "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
9791 "EXPORT_FILE_NAME" "EXPORT_TITLE")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9792 "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
9793 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
9794
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9795 (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
9796 "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
9797
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9798 (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
9799 "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
9800
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9801 (defconst org-clock-drawer-start-re "^[ \t]*:CLOCK:[ \t]*$"
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9802 "Regular expression matching the first line of a property drawer.")
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9803
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9804 (defconst org-clock-drawer-end-re "^[ \t]*:END:[ \t]*$"
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9805 "Regular expression matching the first line of a property drawer.")
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9806
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9807 (defconst org-property-drawer-re
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9808 (concat "\\(" org-property-start-re "\\)[^\000]*\\("
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9809 org-property-end-re "\\)\n?")
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9810 "Matches an entire property drawer.")
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9811
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9812 (defconst org-clock-drawer-re
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9813 (concat "\\(" org-clock-drawer-start-re "\\)[^\000]*\\("
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9814 org-property-end-re "\\)\n?")
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9815 "Matches an entire clock drawer.")
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
9816
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9817 (defun org-property-action ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9818 "Do an action on properties."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9819 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9820 (let (c)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9821 (org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9822 (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
9823 (setq c (read-char-exclusive))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9824 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9825 ((equal c ?s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9826 (call-interactively 'org-set-property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9827 ((equal c ?d)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9828 (call-interactively 'org-delete-property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9829 ((equal c ?D)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9830 (call-interactively 'org-delete-property-globally))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9831 ((equal c ?c)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9832 (call-interactively 'org-compute-property-at-point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9833 (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
9834
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9835 (defun org-at-property-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9836 "Is the cursor in a property line?"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9837 ;; 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
9838 ;; FIXME: also returns true on any drawers.....
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9839 ;; 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
9840 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9841 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9842 (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
9843
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9844 (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
9845 "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
9846 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
9847 they will be found.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9848 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
9849 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9850 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9851 (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
9852 (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
9853 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9854 (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
9855 (setq beg (1+ (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9856 (if force
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9857 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9858 (org-insert-property-drawer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9859 (setq end (progn (outline-next-heading) (point))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9860 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9861 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9862 (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
9863 (setq beg (1+ (match-end 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9864 (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
9865 (setq end (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9866 (or force (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9867 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9868 (setq end beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9869 (org-indent-line-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9870 (insert ":END:\n"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9871 (cons beg end)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9872
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9873 (defun org-entry-properties (&optional pom which)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9874 "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
9875 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
9876 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
9877 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
9878 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
9879 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
9880 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
9881 `special' or `standard', only get that subclass."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9882 (setq which (or which 'all))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9883 (org-with-point-at pom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9884 (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
9885 (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9886 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
9887 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9888 (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
9889 (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9890 (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
9891 (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
9892 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9893 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9894 (when (memq which '(all special))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9895 ;; 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
9896 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9897 (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
9898 (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
9899 (when (looking-at org-priority-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9900 (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
9901 (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
9902 (string-match "\\S-" value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9903 (push (cons "TAGS" value) props))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9904 (when (setq value (org-get-tags-at))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9905 (push (cons "ALLTAGS" (concat ":" (mapconcat 'identity value ":") ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9906 props))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9907 (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
9908 (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
9909 string (if (equal key clockstr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9910 (org-no-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9911 (org-trim
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9912 (buffer-substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9913 (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
9914 (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
9915 (unless key
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9916 (if (= (char-after (match-beginning 3)) ?\[)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9917 (setq key "TIMESTAMP_IA")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9918 (setq key "TIMESTAMP")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9919 (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
9920 (push (cons key string) props)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9921
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9922 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9923
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9924 (when (memq which '(all standard))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9925 ;; Get the standard properties, like :PORP: ...
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9926 (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
9927 (when range
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9928 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9929 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9930 (org-re "^[ \t]*:\\([[:alpha:]][[:alnum:]_-]*\\):[ \t]*\\(\\S-.*\\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9931 (cdr range) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9932 (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
9933 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
9934 (unless (member key excluded)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9935 (push (cons key (or value "")) props)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9936 (if clocksum
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9937 (push (cons "CLOCKSUM"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9938 (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
9939 'add_times))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9940 props))
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9941 (unless (assoc "CATEGORY" props)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9942 (setq value (or (org-get-category)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9943 (progn (org-refresh-category-properties)
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9944 (org-get-category))))
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
9945 (push (cons "CATEGORY" value) props))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9946 (append sum-props (nreverse props)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9947
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9948 (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
9949 "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
9950 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
9951 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
9952 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
9953 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
9954 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
9955 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
9956 (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
9957 (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
9958 (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
9959 t))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9960 (org-entry-get-with-inheritance property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9961 (if (member property org-special-properties)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9962 ;; 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
9963 (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
9964 (let ((range (org-get-property-block)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9965 (if (and range
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9966 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9967 (re-search-forward
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9968 (concat "^[ \t]*:" property ":[ \t]*\\(.*[^ \t\r\n\f\v]\\)?")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9969 (cdr range) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9970 ;; Found the property, return it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9971 (if (match-end 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9972 (org-match-string-no-properties 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9973 "")))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9974
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9975 (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
9976 "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
9977 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
9978 (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
9979 (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
9980 (read prop)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9981 (symbol-value var))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
9982
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9983 (defun org-entry-delete (pom property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9984 "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
9985 (org-with-point-at pom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9986 (if (member property org-special-properties)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9987 nil ; cannot delete these properties.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9988 (let ((range (org-get-property-block)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9989 (if (and range
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9990 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9991 (re-search-forward
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
9992 (concat "^[ \t]*:" property ":[ \t]*\\(.*[^ \t\r\n\f\v]\\)")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9993 (cdr range) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9994 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9995 (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
9996 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9997 nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9998
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9999 ;; 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
10000 ;; 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
10001 (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
10002 "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
10003 (let* ((old (org-entry-get pom property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10004 (values (and old (org-split-string old "[ \t]"))))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10005 (setq value (org-entry-protect-space value))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10006 (unless (member value values)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10007 (setq values (cons value values))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10008 (org-entry-put pom property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10009 (mapconcat 'identity values " ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10010
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10011 (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
10012 "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
10013 (let* ((old (org-entry-get pom property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10014 (values (and old (org-split-string old "[ \t]"))))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10015 (setq value (org-entry-protect-space value))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10016 (when (member value values)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10017 (setq values (delete value values))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10018 (org-entry-put pom property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10019 (mapconcat 'identity values " ")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10020
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10021 (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
10022 "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
10023 (let* ((old (org-entry-get pom property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10024 (values (and old (org-split-string old "[ \t]"))))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10025 (setq value (org-entry-protect-space value))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10026 (member value values)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10027
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10028 (defun org-entry-get-multivalued-property (pom property)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10029 "Return a list of values in a multivalued property."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10030 (let* ((value (org-entry-get pom property))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10031 (values (and value (org-split-string value "[ \t]"))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10032 (mapcar 'org-entry-restore-space values)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10033
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10034 (defun org-entry-put-multivalued-property (pom property &rest values)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10035 "Set multivalued PROPERTY at point-or-marker POM to VALUES.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10036 VALUES should be a list of strings. Spaces will be protected."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10037 (org-entry-put pom property
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10038 (mapconcat 'org-entry-protect-space values " "))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10039 (let* ((value (org-entry-get pom property))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10040 (values (and value (org-split-string value "[ \t]"))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10041 (mapcar 'org-entry-restore-space values)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10042
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10043 (defun org-entry-protect-space (s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10044 "Protect spaces and newline in string S."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10045 (while (string-match " " s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10046 (setq s (replace-match "%20" t t s)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10047 (while (string-match "\n" s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10048 (setq s (replace-match "%0A" t t s)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10049 s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10050
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10051 (defun org-entry-restore-space (s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10052 "Restore spaces and newline in string S."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10053 (while (string-match "%20" s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10054 (setq s (replace-match " " t t s)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10055 (while (string-match "%0A" s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10056 (setq s (replace-match "\n" t t s)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10057 s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10058
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10059 (defvar org-entry-property-inherited-from (make-marker)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10060 "Marker pointing to the entry from where a proerty was inherited.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10061 Each call to `org-entry-get-with-inheritance' will set this marker to the
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10062 location of the entry where the inheriance search matched. If there was
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10063 no match, the marker will point nowhere.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10064 Note that also `org-entry-get' calls this function, if the INHERIT flag
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10065 is set.")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10066
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10067 (defun org-entry-get-with-inheritance (property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10068 "Get entry property, and search higher levels if not present."
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10069 (move-marker org-entry-property-inherited-from nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10070 (let (tmp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10071 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10072 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10073 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10074 (catch 'ex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10075 (while t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10076 (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
10077 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10078 (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
10079 (throw 'ex tmp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10080 (or (org-up-heading-safe) (throw 'ex nil)))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
10081 (or tmp
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10082 (cdr (assoc property org-file-properties))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10083 (cdr (assoc property org-global-properties))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10084 (cdr (assoc property org-global-properties-fixed))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10085
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10086 (defun org-entry-put (pom property value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10087 "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
10088 (org-with-point-at pom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10089 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10090 (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
10091 range)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10092 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10093 ((equal property "TODO")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10094 (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
10095 (not (member value org-todo-keywords-1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10096 (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
10097 (if (or (not value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10098 (not (string-match "\\S-" value)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10099 (setq value 'none))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10100 (org-todo value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10101 (org-set-tags nil 'align))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10102 ((equal property "PRIORITY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10103 (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
10104 (string-to-char value) ?\ ))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10105 (org-set-tags nil 'align))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10106 ((equal property "SCHEDULED")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10107 (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
10108 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10109 ((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
10110 ((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
10111 (t (call-interactively 'org-schedule)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10112 (call-interactively 'org-schedule)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10113 ((equal property "DEADLINE")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10114 (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
10115 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10116 ((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
10117 ((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
10118 (t (call-interactively 'org-deadline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10119 (call-interactively 'org-deadline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10120 ((member property org-special-properties)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10121 (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
10122 property))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10123 (t ; a non-special property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10124 (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
10125 (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
10126 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10127 (if (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10128 (concat "^[ \t]*:" property ":\\(.*\\)") (cdr range) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10129 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10130 (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
10131 (goto-char (match-beginning 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10132 (goto-char (cdr range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10133 (insert "\n")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10134 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10135 (org-indent-line-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10136 (insert ":" property ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10137 (and value (insert " " value))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10138 (org-indent-line-function)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10139
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10140 (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
10141 "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
10142 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
10143 like tags and TODO state.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10144 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
10145 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
10146 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
10147 formats in the current buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10148 (let (rtn range cfmt cols s p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10149 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10150 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10151 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10152 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10153 (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
10154 (setq range (org-get-property-block))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10155 (goto-char (car range))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10156 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10157 (org-re "^[ \t]*:\\([-[:alnum:]_]+\\):")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10158 (cdr range) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10159 (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
10160 (outline-next-heading))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10161
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10162 (when include-specials
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10163 (setq rtn (append org-special-properties rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10164
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10165 (when include-defaults
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10166 (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
10167
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10168 (when include-columns
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10169 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10170 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10171 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10172 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10173 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10174 "^\\(#\\+COLUMNS:\\|[ \t]*:COLUMNS:\\)[ \t]*\\(.*\\)"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10175 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10176 (setq cfmt (match-string 2) s 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10177 (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
10178 cfmt s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10179 (setq s (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10180 p (match-string 1 cfmt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10181 (unless (or (equal p "ITEM")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10182 (member p org-special-properties))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10183 (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
10184
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10185 (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
10186
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10187 (defun org-property-values (key)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10188 "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
10189 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10190 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10191 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10192 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10193 (let ((re (concat "^[ \t]*:" key ":[ \t]*\\(\\S-.*\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10194 values)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10195 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10196 (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
10197 (delete "" values)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10198
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10199 (defun org-insert-property-drawer ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10200 "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
10201 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10202 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10203 (looking-at outline-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10204 (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
10205 (beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10206 (re (concat "^[ \t]*" org-keyword-time-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10207 end hiddenp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10208 (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10209 (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10210 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10211 (while (re-search-forward re end t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10212 (setq hiddenp (org-invisible-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10213 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10214 (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
10215 (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
10216 (beginning-of-line 2))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10217 (org-skip-over-state-notes)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10218 (skip-chars-backward " \t\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10219 (if (eq (char-before) ?*) (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10220 (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
10221 (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
10222 (org-indent-to-column indent)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10223 (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
10224 (org-indent-to-column indent)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10225 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10226 (if hiddenp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10227 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10228 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10229 (hide-entry))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10230 (org-flag-drawer t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10231
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10232 (defun org-set-property (property value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10233 "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
10234 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
10235 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
10236 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
10237 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
10238 in the current file."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10239 (interactive
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10240 (let* ((completion-ignore-case t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10241 (keys (org-buffer-property-keys nil t t))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10242 (prop0 (completing-read "Property: " (mapcar 'list keys)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10243 (prop (if (member prop0 keys)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10244 prop0
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10245 (or (cdr (assoc (downcase prop0)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10246 (mapcar (lambda (x) (cons (downcase x) x))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10247 keys)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10248 prop0)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10249 (cur (org-entry-get nil prop))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10250 (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
10251 (existing (mapcar 'list (org-property-values prop)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10252 (val (if allowed
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10253 (org-completing-read "Value: " allowed nil 'req-match)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10254 (org-completing-read
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10255 (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
10256 (concat "[" cur "]") "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10257 ": ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10258 existing nil nil "" nil cur))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10259 (list prop (if (equal val "") cur val))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10260 (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
10261 (org-entry-put nil property value)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10262
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10263 (defun org-delete-property (property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10264 "In the current entry, delete PROPERTY."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10265 (interactive
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10266 (let* ((completion-ignore-case t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10267 (prop (completing-read
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10268 "Property: " (org-entry-properties nil 'standard))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10269 (list prop)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10270 (message "Property %s %s" property
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10271 (if (org-entry-delete nil property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10272 "deleted"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10273 "was not present in the entry")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10274
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10275 (defun org-delete-property-globally (property)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10276 "Remove PROPERTY globally, from all entries."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10277 (interactive
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10278 (let* ((completion-ignore-case t)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10279 (prop (completing-read
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10280 "Globally remove property: "
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10281 (mapcar 'list (org-buffer-property-keys)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10282 (list prop)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10283 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10284 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10285 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10286 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10287 (let ((cnt 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10288 (while (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10289 (concat "^[ \t]*:" (regexp-quote property) ":.*\n?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10290 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10291 (setq cnt (1+ cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10292 (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10293 (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
10294
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10295 (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
10296
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10297 (defun org-compute-property-at-point ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10298 "Compute the property at point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10299 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
10300 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
10301 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10302 (unless (org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10303 (error "Not at a property"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10304 (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
10305 (org-columns-get-format-and-top-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10306 (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
10307 (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
10308 (org-columns-compute prop)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10309
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10310 (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
10311 "Get allowed values for the property PROPERTY.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10312 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
10313 completion."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10314 (let (vals)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10315 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10316 ((equal property "TODO")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10317 (setq vals (org-with-point-at pom
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10318 (append org-todo-keywords-1 '("")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10319 ((equal property "PRIORITY")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10320 (let ((n org-lowest-priority))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10321 (while (>= n org-highest-priority)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10322 (push (char-to-string n) vals)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10323 (setq n (1- n)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10324 ((member property org-special-properties))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10325 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10326 (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
10327
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10328 (when (and vals (string-match "\\S-" vals))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10329 (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
10330 (setq vals (mapcar (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10331 (cond ((stringp x) x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10332 ((numberp x) (number-to-string x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10333 ((symbolp x) (symbol-name x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10334 (t "???")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10335 vals)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10336 (if table (mapcar 'list vals) vals)))
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-property-previous-allowed-value (&optional previous)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10339 "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
10340 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10341 (org-property-next-allowed-value t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10342
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10343 (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
10344 "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
10345 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10346 (unless (org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10347 (error "Not at a property"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10348 (let* ((key (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10349 (value (match-string 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10350 (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
10351 (and (member value '("[ ]" "[-]" "[X]"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10352 '("[ ]" "[X]"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10353 nval)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10354 (unless allowed
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10355 (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
10356 (if previous (setq allowed (reverse allowed)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10357 (if (member value allowed)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10358 (setq nval (car (cdr (member value allowed)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10359 (setq nval (or nval (car allowed)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10360 (if (equal nval value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10361 (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
10362 (org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10363 (replace-match (concat " :" key ": " nval) t t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10364 (org-indent-line-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10365 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10366 (skip-chars-forward " \t")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10367
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10368 (defun org-find-entry-with-id (ident)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10369 "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
10370 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
10371 the string representation of it.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10372 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
10373 (let ((id (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10374 ((stringp ident) ident)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10375 ((symbol-name ident) (symbol-name ident))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10376 ((numberp ident) (number-to-string ident))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10377 (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
10378 (case-fold-search nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10379 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10380 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10381 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10382 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10383 (when (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10384 (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
10385 nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10386 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10387 (point))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10388
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10389 ;;;; Timestamps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10390
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10391 (defvar org-last-changed-timestamp nil)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10392 (defvar org-last-inserted-timestamp nil
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10393 "The last time stamp inserted with `org-insert-time-stamp'.")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10394 (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
10395 (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
10396 (defvar org-ts-what) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10397
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10398 (defun org-time-stamp (arg &optional inactive)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10399 "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
10400 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
10401 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
10402 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
10403 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
10404 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
10405 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
10406 at the cursor, it will be modified."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10407 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10408 (let* ((ts nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10409 (default-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10410 ;; 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
10411 ;; the range start.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10412 (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
10413 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10414 (re-search-backward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10415 (concat org-ts-regexp "--?-?\\=") ; 1-3 minuses
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10416 (- (point) 20) t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10417 (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
10418 (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10419 (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
10420 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
10421 (cond
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10422 ((and (org-at-timestamp-p t)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10423 (memq last-command '(org-time-stamp org-time-stamp-inactive))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10424 (memq this-command '(org-time-stamp org-time-stamp-inactive)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10425 (insert "--")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10426 (setq time (let ((this-command this-command))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10427 (org-read-date arg 'totime nil nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10428 default-time default-input)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10429 (org-insert-time-stamp time (or org-time-was-given arg) inactive))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10430 ((org-at-timestamp-p t)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10431 (setq time (let ((this-command this-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10432 (org-read-date arg 'totime nil nil default-time default-input)))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10433 (when (org-at-timestamp-p t) ; just to get the match data
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10434 ; (setq inactive (eq (char-after (match-beginning 0)) ?\[))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10435 (replace-match "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10436 (setq org-last-changed-timestamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10437 (org-insert-time-stamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10438 time (or org-time-was-given arg)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10439 inactive nil nil (list org-end-time-was-given))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10440 (message "Timestamp updated"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10441 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10442 (setq time (let ((this-command this-command))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10443 (org-read-date arg 'totime nil nil default-time default-input)))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10444 (org-insert-time-stamp time (or org-time-was-given arg) inactive
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10445 nil nil (list org-end-time-was-given))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10446
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10447 ;; 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
10448 (defun org-get-compact-tod (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10449 (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
10450 (let* ((t1 (match-string 1 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10451 (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
10452 (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
10453 (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
10454 (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
10455 (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
10456 dh dm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10457 (if (not t2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10458 t1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10459 (setq dh (- h2 h1) dm (- m2 m1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10460 (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
10461 (concat t1 "+" (number-to-string dh)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10462 (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
10463
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10464 (defun org-time-stamp-inactive (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10465 "Insert an inactive time stamp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10466 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
10467 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
10468 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
10469 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
10470 (interactive "P")
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10471 (org-time-stamp arg 'inactive))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10472
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10473 (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
10474 (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
10475 (org-detach-overlay org-date-ovl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10476
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10477 (defvar org-ans1) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10478 (defvar org-ans2) ; dynamically scoped parameter
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10479
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10480 (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
10481
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10482 (defvar org-overriding-default-time nil) ; dynamically scoped
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10483 (defvar org-read-date-overlay nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10484 (defvar org-dcst nil) ; dynamically scoped
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-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
10487 default-time default-input)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10488 "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
10489 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
10490 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
10491 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
10492 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
10493 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
10494 existing stamp. For example,
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10495 3-2-5 --> 2003-02-05
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10496 feb 15 --> currentyear-02-15
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10497 sep 12 9 --> 2009-09-12
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10498 12:45 --> today 12:45
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10499 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
10500 12 --> currentyear-currentmonth-12
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10501 Fri --> nearest Friday (today or later)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10502 etc.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10503
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10504 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
10505 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
10506 change in days weeks, months, years.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10507 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
10508 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
10509 +4d --> four days from today
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10510 +4 --> same as above
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10511 +2w --> two weeks from today
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10512 ++5 --> five days from default date
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10513
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10514 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
10515 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
10516 `parse-time-weekdays'.
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 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
10519 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
10520 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
10521 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
10522 \(setq org-read-date-popup-calendar nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10523
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10524 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
10525 to an internal time.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10526 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
10527 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
10528 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
10529 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
10530 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
10531 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
10532 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
10533 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
10534 user."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10535 (require 'parse-time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10536 (let* ((org-time-stamp-rounding-minutes
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10537 (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
10538 (org-dcst org-display-custom-times)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10539 (ct (org-current-time))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10540 (def (or org-overriding-default-time default-time ct))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10541 (defdecode (decode-time def))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10542 (dummy (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10543 (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
10544 (setcar (nthcdr 2 defdecode) -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10545 (setcar (nthcdr 1 defdecode) 59)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10546 (setq def (apply 'encode-time defdecode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10547 defdecode (decode-time def)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10548 (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
10549 (calendar-view-diary-initially-flag nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10550 (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
10551 (calendar-view-holidays-initially-flag nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10552 (view-calendar-holidays-initially nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10553 (timestr (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10554 (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
10555 (prompt (concat (if prompt (concat prompt " ") "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10556 (format "Date+time [%s]: " timestr)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10557 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
10558
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10559 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10560 (from-string (setq ans from-string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10561 (org-read-date-popup-calendar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10562 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10563 (save-window-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10564 (calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10565 (calendar-forward-day (- (time-to-days def)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10566 (calendar-absolute-from-gregorian
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10567 (calendar-current-date))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10568 (org-eval-in-calendar nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10569 (let* ((old-map (current-local-map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10570 (map (copy-keymap calendar-mode-map))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10571 (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
10572 (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
10573 (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
10574 'org-calendar-select-mouse)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10575 (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
10576 'org-calendar-select-mouse)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10577 (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
10578 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10579 (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
10580 (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
10581 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10582 (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
10583 (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
10584 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10585 (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
10586 (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
10587 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10588 (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
10589 (org-defkey minibuffer-local-map [(shift up)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10590 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10591 (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
10592 (org-defkey minibuffer-local-map [(shift down)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10593 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10594 (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
10595 (org-defkey minibuffer-local-map [(shift left)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10596 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10597 (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
10598 (org-defkey minibuffer-local-map [(shift right)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10599 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10600 (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
10601 (org-defkey minibuffer-local-map ">"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10602 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10603 (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
10604 (org-defkey minibuffer-local-map "<"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10605 (lambda () (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10606 (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
10607 (unwind-protect
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10608 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10609 (use-local-map map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10610 (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
10611 (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
10612 ;; org-ans0: from prompt
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10613 ;; org-ans1: from mouse click
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10614 ;; org-ans2: from calendar motion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10615 (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
10616 (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
10617 (use-local-map old-map)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10618 (when org-read-date-overlay
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10619 (org-delete-overlay org-read-date-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10620 (setq org-read-date-overlay nil)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10621
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10622 (t ; Naked prompt only
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10623 (unwind-protect
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10624 (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
10625 (when org-read-date-overlay
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10626 (org-delete-overlay org-read-date-overlay)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10627 (setq org-read-date-overlay nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10628
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10629 (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
10630
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10631 (if to-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10632 (apply 'encode-time final)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10633 (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
10634 (format "%04d-%02d-%02d %02d:%02d"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10635 (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
10636 (nth 2 final) (nth 1 final))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10637 (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
10638 (defvar def)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10639 (defvar defdecode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10640 (defvar with-time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10641 (defun org-read-date-display ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10642 "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
10643 (when org-read-date-display-live
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10644 (when org-read-date-overlay
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10645 (org-delete-overlay org-read-date-overlay))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10646 (let ((p (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10647 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10648 (while (not (equal (buffer-substring
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10649 (max (point-min) (- (point) 4)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10650 " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10651 (insert " "))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10652 (goto-char p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10653 (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
10654 " " (or org-ans1 org-ans2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10655 (org-end-time-was-given nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10656 (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
10657 (fmts (if org-dcst
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10658 org-time-stamp-custom-formats
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10659 org-time-stamp-formats))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10660 (fmt (if (or with-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10661 (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
10662 (cdr fmts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10663 (car fmts)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10664 (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
10665 (when (and org-end-time-was-given
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10666 (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
10667 (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
10668 org-end-time-was-given
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10669 (substring txt (match-end 0)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10670 (setq org-read-date-overlay
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
10671 (org-make-overlay (1- (point-at-eol)) (point-at-eol)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10672 (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
10673
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10674 (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
10675 "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
10676 ;; FIXME: cleanup and comment
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10677 (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
10678 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
10679 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
10680
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10681 (when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10682 (setq ans "+0"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10683
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10684 (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
10685 (setq ans (replace-match "" t t ans)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10686 deltan (car delta)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10687 deltaw (nth 1 delta)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10688 deltadef (nth 2 delta)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10689
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10690 ;; 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
10691 ;; 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
10692 ;; 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
10693 (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
10694 (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
10695 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
10696 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
10697 (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
10698
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10699 ;; 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
10700 (when (string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10701 "^ *\\(\\([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
10702 (setq year (if (match-end 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10703 (string-to-number (match-string 2 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10704 (string-to-number (format-time-string "%Y")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10705 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
10706 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
10707 (if (< year 100) (setq year (+ 2000 year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10708 (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
10709 t nil ans)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10710 ;; 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
10711 ;; 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
10712 ;; so that matching will be successful.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10713 (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
10714 (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
10715 (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
10716 (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
10717 minute (if (match-end 3)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10718 (string-to-number (match-string 3 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10719 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10720 pm (equal ?p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10721 (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
10722 (if (and (= hour 12) (not pm))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10723 (setq hour 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10724 (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
10725 (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
10726 t t ans))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10727
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10728 ;; 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
10729 (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
10730 (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
10731 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
10732 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
10733 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
10734 (match-string 5 ans))0)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10735 (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
10736 (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
10737 t t ans)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10738
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10739 ;; Check if there is a time range
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10740 (when (boundp 'org-end-time-was-given)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10741 (setq org-time-was-given nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10742 (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
10743 (match-end 8))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10744 (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
10745 (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
10746 (substring ans (match-end 7))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10747
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10748 (setq tl (parse-time-string ans)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10749 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
10750 month (or (nth 4 tl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10751 (if (and org-read-date-prefer-future
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10752 (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
10753 (1+ (nth 4 defdecode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10754 (nth 4 defdecode)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10755 year (or (nth 5 tl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10756 (if (and org-read-date-prefer-future
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10757 (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
10758 (1+ (nth 5 defdecode))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10759 (nth 5 defdecode)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10760 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
10761 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
10762 second (or (nth 0 tl) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10763 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
10764
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10765 ;; Special date definitions below
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10766 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10767 (iso-week
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10768 ;; 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
10769 (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
10770 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
10771 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
10772 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
10773 (calendar-absolute-from-iso
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10774 (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
10775 ; 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
10776 ; (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
10777 ; (not iso-year)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10778 ; (< (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
10779 ; (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
10780 ; (setq year (1+ year)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10781 ; 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
10782 ; (calendar-absolute-from-iso
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
10783 ; (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
10784 (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
10785 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
10786 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
10787 (deltan
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10788 (unless deltadef
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10789 (let ((now (decode-time (current-time))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10790 (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
10791 (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
10792 ((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
10793 ((equal deltaw "m") (setq month (+ month deltan)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10794 ((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
10795 ((and wday (not (nth 3 tl)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10796 ;; 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
10797 ;; on or after the derived date.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10798 (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
10799 (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
10800 (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
10801 (if (and (boundp 'org-time-was-given)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10802 (nth 2 tl))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10803 (setq org-time-was-given t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10804 (if (< year 100) (setq year (+ 2000 year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10805 (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
10806 (list second minute hour day month year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10807
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10808 (defvar parse-time-weekdays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10809
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10810 (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
10811 "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
10812 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
10813 Return shift list (N what def-flag)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10814 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
10815 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
10816 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
10817 the DEFAULT date rather than TODAY."
94749
494fe8a4eeb0 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 94676
diff changeset
10818 (when (and
494fe8a4eeb0 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 94676
diff changeset
10819 (string-match
494fe8a4eeb0 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 94676
diff changeset
10820 (concat
494fe8a4eeb0 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 94676
diff changeset
10821 "\\`[ \t]*\\([-+]\\{0,2\\}\\)"
494fe8a4eeb0 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 94676
diff changeset
10822 "\\([0-9]+\\)?"
494fe8a4eeb0 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 94676
diff changeset
10823 "\\([dwmy]\\|\\(" (mapconcat 'car parse-time-weekdays "\\|") "\\)\\)?"
494fe8a4eeb0 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 94676
diff changeset
10824 "\\([ \t]\\|$\\)") s)
494fe8a4eeb0 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 94676
diff changeset
10825 (or (> (match-end 1) (match-beginning 1)) (match-end 4)))
494fe8a4eeb0 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 94676
diff changeset
10826 (let* ((dir (if (> (match-end 1) (match-beginning 1))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10827 (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
10828 ?+))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10829 (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
10830 (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
10831 (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
10832 (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
10833 (date (if rel default today))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10834 (wday (nth 6 (decode-time date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10835 delta)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10836 (if wday1
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10837 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10838 (setq delta (mod (+ 7 (- wday1 wday)) 7))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10839 (if (= dir ?-) (setq delta (- delta 7)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10840 (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
10841 (list delta "d" rel))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10842 (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
10843
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10844 (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
10845 "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
10846 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
10847 (let ((sw (selected-window)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10848 (select-window (get-buffer-window "*Calendar*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10849 (eval form)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10850 (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
10851 (let* ((date (calendar-cursor-to-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10852 (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
10853 (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
10854 (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
10855 (select-window sw)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10856
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10857 (defun org-calendar-select ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10858 "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
10859 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
10860 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10861 (when (calendar-cursor-to-date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10862 (let* ((date (calendar-cursor-to-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10863 (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
10864 (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
10865 (if (active-minibuffer-window) (exit-minibuffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10866
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10867 (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
10868 "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
10869 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
10870 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
10871 stamp will not contribute to the agenda.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10872 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
10873 stamp.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10874 The command returns the inserted time stamp."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10875 (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
10876 stamp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10877 (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
10878 (insert-before-markers (or pre ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10879 (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
10880 (when (listp extra)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10881 (setq extra (car extra))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10882 (if (and (stringp extra)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10883 (string-match "\\([0-9]+\\):\\([0-9]+\\)" extra))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10884 (setq extra (format "-%02d:%02d"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10885 (string-to-number (match-string 1 extra))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10886 (string-to-number (match-string 2 extra))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10887 (setq extra nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10888 (when extra
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10889 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10890 (insert-before-markers extra)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10891 (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10892 (insert-before-markers (or post ""))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10893 (setq org-last-inserted-timestamp stamp)))
93141
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-toggle-time-stamp-overlays ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10896 "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
10897 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10898 (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
10899 (unless org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10900 (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
10901 (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
10902 (if (and (get-text-property p 'display)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10903 (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
10904 (remove-text-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10905 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
10906 '(display t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10907 (set-buffer-modified-p bmp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10908 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10909 (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
10910 (org-restart-font-lock)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10911 (setq org-table-may-need-update t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10912 (if org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10913 (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
10914 (message "Time stamp overlays removed")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10915
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10916 (defun org-display-custom-time (beg end)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
10917 "Overlay modified time stamp format over timestamp between BEG and END."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10918 (let* ((ts (buffer-substring beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10919 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
10920 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10921 (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
10922 (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
10923 (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
10924 (setq end (- end off))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10925 (setq w1 (- end beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10926 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
10927 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
10928 time (org-fix-decoded-time t1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10929 str (org-add-props
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10930 (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10931 (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
10932 nil 'mouse-face 'highlight)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10933 w2 (length str))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10934 (if (not (= w2 w1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10935 (add-text-properties (1+ beg) (+ 2 beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10936 (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
10937 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10938 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10939 (put-text-property beg end 'invisible t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10940 (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
10941 (put-text-property beg end 'display str))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10942
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10943 (defun org-translate-time (string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10944 "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
10945 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
10946 (when org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10947 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10948 (let* ((start 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10949 (re org-ts-regexp-both)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10950 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
10951 (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
10952 (setq beg (match-beginning 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10953 end (match-end 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10954 t1 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10955 (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
10956 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
10957 inactive (equal (substring string beg (1+ beg)) "[")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10958 tf (funcall (if with-hm 'cdr 'car)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10959 org-time-stamp-custom-formats)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10960 time (org-fix-decoded-time t1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10961 str (format-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10962 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10963 (if inactive "[" "<") (substring tf 1 -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10964 (if inactive "]" ">"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10965 (apply 'encode-time time))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10966 string (replace-match str t t string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10967 start (+ start (length str)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10968 string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10969
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10970 (defun org-fix-decoded-time (time)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10971 "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
10972 Don't touch the rest."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10973 (let ((n 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10974 (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
10975
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10976 (defun org-days-to-time (timestamp-string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10977 "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
10978 (- (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
10979 (time-to-days (current-time))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10980
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10981 (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
10982 "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
10983 (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
10984 (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
10985 (not (org-entry-is-done-p))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10986
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10987 (defun org-get-wdays (ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10988 "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
10989 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10990 ((<= org-deadline-warning-days 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10991 ;; 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
10992 (- org-deadline-warning-days))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10993 ((string-match "-\\([0-9]+\\)\\([dwmy]\\)\\(\\'\\|>\\)" ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10994 ;; lead time is specified.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10995 (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
10996 (cdr (assoc (match-string 2 ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10997 '(("d" . 1) ("w" . 7)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10998 ("m" . 30.4) ("y" . 365.25)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10999 ;; go for the default.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11000 (t org-deadline-warning-days)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11001
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11002 (defun org-calendar-select-mouse (ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11003 "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
11004 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
11005 (interactive "e")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11006 (mouse-set-point ev)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11007 (when (calendar-cursor-to-date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11008 (let* ((date (calendar-cursor-to-date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11009 (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
11010 (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
11011 (if (active-minibuffer-window) (exit-minibuffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11012
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11013 (defun org-check-deadlines (ndays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11014 "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
11015 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
11016 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
11017 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
11018 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
11019 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11020 (let* ((org-warn-days
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11021 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11022 ((equal ndays '(4)) 100000)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11023 (ndays (prefix-numeric-value ndays))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11024 (t (abs org-deadline-warning-days))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11025 (case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11026 (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11027 (callback
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11028 (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
11029
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11030 (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
11031 (org-occur regexp nil callback)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11032 org-warn-days)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11033
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11034 (defun org-check-before-date (date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11035 "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
11036 (interactive (list (org-read-date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11037 (let ((case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11038 (regexp (concat "\\<\\(" org-deadline-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11039 "\\|" org-scheduled-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11040 "\\) *<\\([^>]+\\)>"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11041 (callback
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11042 (lambda () (time-less-p
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11043 (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
11044 (org-time-string-to-time date)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11045 (message "%d entries before %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11046 (org-occur regexp nil callback) date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11047
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11048 (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
11049 "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
11050 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
11051 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
11052 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
11053 next column.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11054 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
11055 days in order to avoid rounding problems."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11056 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11057 (or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11058 (org-clock-update-time-maybe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11059 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11060 (unless (org-at-date-range-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11061 (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11062 (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
11063 (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
11064 (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
11065 (let* ((ts1 (match-string 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11066 (ts2 (match-string 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11067 (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
11068 (match-end (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11069 (time1 (org-time-string-to-time ts1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11070 (time2 (org-time-string-to-time ts2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11071 (t1 (time-to-seconds time1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11072 (t2 (time-to-seconds time2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11073 (diff (abs (- t2 t1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11074 (negative (< (- t2 t1) 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11075 ;; (ys (floor (* 365 24 60 60)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11076 (ds (* 24 60 60))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11077 (hs (* 60 60))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11078 (fy "%dy %dd %02d:%02d")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11079 (fy1 "%dy %dd")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11080 (fd "%dd %02d:%02d")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11081 (fd1 "%dd")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11082 (fh "%02d:%02d")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11083 y d h m align)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11084 (if havetime
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11085 (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
11086 y 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11087 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
11088 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
11089 m (floor (/ diff 60)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11090 (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
11091 y 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11092 d (floor (+ (/ diff ds) 0.5))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11093 h 0 m 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11094 (if (not to-buffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11095 (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
11096 (if (org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11097 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11098 (goto-char match-end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11099 (setq align t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11100 (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
11101 (goto-char match-end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11102 (if (looking-at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11103 "\\( *-? *[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
11104 (replace-match ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11105 (if negative (insert " -"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11106 (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
11107 (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
11108 (insert " " (format fh h m))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11109 (if align (org-table-align))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11110 (message "Time difference inserted")))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11111
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11112 (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
11113 (let ((fmt "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11114 (l nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11115 (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
11116 l (push y l)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11117 (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
11118 l (push d l)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11119 (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
11120 l (push h l)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11121 (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
11122 l (push m l)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11123 (apply 'format fmt (nreverse l))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11124
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11125 (defun org-time-string-to-time (s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11126 (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
11127
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11128 (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
11129 "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
11130 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
11131 DAYNR.
99655
700e59a3b82f * emulation/viper-cmd.el (viper-harness-minor-mode): Fix docstring typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 99514
diff changeset
11132 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
11133 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11134 ((and daynr (string-match "\\`%%\\((.*)\\)" s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11135 (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
11136 daynr
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11137 (+ daynr 1000)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11138 ((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
11139 (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
11140 (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
11141 prefer show-all))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11142 (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
11143
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11144 (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
11145 "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
11146 (require 'cal-iso)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11147 (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
11148
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11149 (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
11150 "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
11151 38-99 are mapped into 1938-1999. 1-37 are mapped into 2001-2007.
99656
e20aa9b3858c Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 99655
diff changeset
11152 The year 2000 cannot be abbreviated. Any year larger than 99
99655
700e59a3b82f * emulation/viper-cmd.el (viper-harness-minor-mode): Fix docstring typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 99514
diff changeset
11153 is returned unchanged."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11154 (if (< year 38)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11155 (setq year (+ 2000 year))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11156 (if (< year 100)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11157 (setq year (+ 1900 year))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11158 year)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11159
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11160 (defun org-time-from-absolute (d)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11161 "Return the time corresponding to date D.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11162 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
11163 (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
11164 (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
11165
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11166 (defun org-calendar-holiday ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11167 "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
11168 (require 'holidays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11169 (let ((hl (funcall
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11170 (if (fboundp 'calendar-check-holidays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11171 'calendar-check-holidays 'check-calendar-holidays) date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11172 (if hl (mapconcat 'identity hl "; "))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11173
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11174 (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
11175 "Process a SEXP diary ENTRY for DATE."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11176 (require 'diary-lib)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11177 (let ((result (if calendar-debug-sexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11178 (let ((stack-trace-on-error t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11179 (eval (car (read-from-string sexp))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11180 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11181 (eval (car (read-from-string sexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11182 (error
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11183 (beep)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11184 (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
11185 (org-current-line)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11186 (buffer-file-name) sexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11187 (sleep-for 2))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11188 (cond ((stringp result) result)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11189 ((and (consp result)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11190 (stringp (cdr result))) (cdr result))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11191 (result entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11192 (t nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11193
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11194 (defun org-diary-to-ical-string (frombuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11195 "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
11196 This uses the icalendar.el library."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11197 (let* ((tmpdir (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11198 (temp-directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11199 temporary-file-directory))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11200 (tmpfile (make-temp-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11201 (expand-file-name "orgics" tmpdir)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11202 buf rtn b e)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11203 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11204 (set-buffer frombuf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11205 (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
11206 (setq buf (find-buffer-visiting tmpfile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11207 (set-buffer buf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11208 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11209 (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
11210 (setq b (match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11211 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11212 (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
11213 (setq e (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11214 (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
11215 (kill-buffer buf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11216 (delete-file tmpfile)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11217 rtn))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11218
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11219 (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
11220 "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
11221 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
11222 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
11223 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
11224 ;; Make the proper lists from the dates
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11225 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11226 (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
11227 dn dw sday cday n1 n2
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11228 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
11229
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11230 (setq start (org-date-to-gregorian start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11231 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
11232 (if show-all
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11233 current
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11234 (time-to-days (current-time))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11235 sday (calendar-absolute-from-gregorian start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11236 cday (calendar-absolute-from-gregorian current))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11237
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11238 (if (<= cday sday) (throw 'exit sday))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11239
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11240 (if (string-match "\\(\\+[0-9]+\\)\\([dwmy]\\)" change)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11241 (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
11242 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
11243 (error "Invalid change specifyer: %s" change))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11244 (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
11245 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11246 ((eq dw 'day)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11247 (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
11248 n2 (+ n1 dn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11249 ((eq dw 'year)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11250 (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
11251 (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
11252 (setq date1 (list m d y1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11253 n1 (calendar-absolute-from-gregorian date1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11254 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
11255 n2 (calendar-absolute-from-gregorian date2)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11256 ((eq dw 'month)
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
11257 ;; approx number of month between the two dates
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11258 (setq nmonths (floor (/ (- cday sday) 30.436875)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11259 ;; How often does dn fit in there?
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11260 (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
11261 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
11262 m (+ m nm)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11263 ny (floor (/ m 12))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11264 y (+ y ny)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11265 m (- m (* ny 12)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11266 (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
11267 (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
11268 (setq m2 (+ m dn) y2 y)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11269 (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
11270 (setq n2 (calendar-absolute-from-gregorian (list m2 d y2)))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
11271 (while (<= n2 cday)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11272 (setq n1 n2 m m2 y y2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11273 (setq m2 (+ m dn) y2 y)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11274 (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
11275 (setq n2 (calendar-absolute-from-gregorian (list m2 d y2))))))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11276 (if show-all
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11277 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11278 ((eq prefer 'past) n1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11279 ((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
11280 (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
11281 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11282 ((eq prefer 'past) n1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11283 ((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
11284 (t (if (= cday n1) n1 n2)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11285
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11286 (defun org-date-to-gregorian (date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11287 "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
11288 (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
11289 ((and (listp date) (= (length date) 3)) date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11290 ((stringp date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11291 (setq date (org-parse-time-string date))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11292 (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
11293 ((listp date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11294 (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
11295
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11296 (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
11297 "Parse the standard Org-mode time string.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11298 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
11299 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
11300 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
11301 (if (string-match org-ts-regexp0 s)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11302 (list 0
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11303 (if (or (match-beginning 8) (not nodefault))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11304 (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
11305 (if (or (match-beginning 7) (not nodefault))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11306 (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
11307 (string-to-number (match-string 4 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11308 (string-to-number (match-string 3 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11309 (string-to-number (match-string 2 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11310 nil nil nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11311 (make-list 9 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11312
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11313 (defun org-timestamp-up (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11314 "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
11315 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
11316 the day, change that.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11317 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
11318 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11319 (org-timestamp-change (prefix-numeric-value arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11320
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11321 (defun org-timestamp-down (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11322 "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
11323 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
11324 the day, change that.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11325 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
11326 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11327 (org-timestamp-change (- (prefix-numeric-value arg))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11328
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11329 (defun org-timestamp-up-day (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11330 "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
11331 With prefix ARG, change that many days."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11332 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11333 (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
11334 (org-on-heading-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11335 (org-todo 'up)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11336 (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
11337
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11338 (defun org-timestamp-down-day (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11339 "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
11340 With prefix ARG, change that many days."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11341 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11342 (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
11343 (org-on-heading-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11344 (org-todo 'down)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11345 (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
11346
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11347 (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
11348 "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
11349 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11350 (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
11351 (pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11352 (ans (or (looking-at tsr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11353 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11354 (skip-chars-backward "^[<\n\r\t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11355 (if (> (point) (point-min)) (backward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11356 (and (looking-at tsr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11357 (> (- (match-end 0) pos) -1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11358 (and ans
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11359 (boundp 'org-ts-what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11360 (setq org-ts-what
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11361 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11362 ((= pos (match-beginning 0)) 'bracket)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11363 ((= pos (1- (match-end 0))) 'bracket)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11364 ((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
11365 ((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
11366 ((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
11367 ((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
11368 ((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
11369 (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
11370 ((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
11371 (< pos (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11372 (- 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
11373 (t 'day))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11374 ans))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11375
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11376 (defun org-toggle-timestamp-type ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11377 "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
11378 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11379 (when (org-at-timestamp-p t)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11380 (let ((beg (match-beginning 0)) (end (match-end 0))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11381 (map '((?\[ . "<") (?\] . ">") (?< . "[") (?> . "]"))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11382 (save-excursion
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11383 (goto-char beg)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11384 (while (re-search-forward "[][<>]" end t)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11385 (replace-match (cdr (assoc (char-after (match-beginning 0)) map))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11386 t t)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11387 (message "Timestamp is now %sactive"
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11388 (if (equal (char-after beg) ?<) "" "in")))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11389
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11390 (defun org-timestamp-change (n &optional what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11391 "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
11392 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
11393 `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
11394 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
11395 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11396 with-hm inactive
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11397 (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
11398 org-ts-what
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11399 extra rem
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11400 ts time time0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11401 (if (not (org-at-timestamp-p t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11402 (error "Not at a timestamp"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11403 (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
11404 (org-toggle-timestamp-type)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11405 (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
11406 org-display-custom-times
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11407 (get-text-property (point) 'display)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11408 (not (get-text-property (1- (point)) 'display)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11409 (setq org-ts-what 'day))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11410 (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
11411 inactive (= (char-after (match-beginning 0)) ?\[)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11412 ts (match-string 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11413 (replace-match "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11414 (if (string-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11415 "\\(\\(-[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
11416 ts)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11417 (setq extra (match-string 1 ts)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11418 (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
11419 (setq with-hm t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11420 (setq time0 (org-parse-time-string ts))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11421 (when (and (eq org-ts-what 'minute)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11422 (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
11423 (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
11424 (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
11425 (setcar (cdr time0) (+ (nth 1 time0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11426 (if (> n 0) (- rem) (- dm rem))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11427 (setq time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11428 (encode-time (or (car time0) 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11429 (+ (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
11430 (+ (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
11431 (+ (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
11432 (+ (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
11433 (+ (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
11434 (nthcdr 6 time0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11435 (when (integerp org-ts-what)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11436 (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
11437 (if (eq what 'calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11438 (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
11439 (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
11440 (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
11441 (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
11442 (setcar time0 (or (car time0) 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11443 (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
11444 (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
11445 (setq time (apply 'encode-time time0))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11446 (setq org-last-changed-timestamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11447 (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
11448 (org-clock-update-time-maybe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11449 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11450 ;; 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
11451 (if (and org-calendar-follow-timestamp-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11452 (get-buffer-window "*Calendar*" t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11453 (memq org-ts-what '(day month year)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11454 (org-recenter-calendar (time-to-days time))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11455
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11456 (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
11457 "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
11458 (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
11459 ng h m new rem)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11460 (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
11461 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11462 ((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
11463 (org-pos-in-match-range pos 3))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11464 (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
11465 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
11466 (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
11467 (setq h (+ h n))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11468 (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
11469 (when (not (= 0 (setq rem (% m dm))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11470 (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
11471 (setq m (+ m n)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11472 (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
11473 (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
11474 (setq h (min 24 (max 0 h)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11475 (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
11476 ((org-pos-in-match-range pos 6)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11477 (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
11478 ((org-pos-in-match-range pos 5)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11479 (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
11480
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11481 ((org-pos-in-match-range pos 9)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11482 (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
11483 ((org-pos-in-match-range pos 8)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11484 (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
11485
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11486 (when ng
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11487 (setq s (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11488 (substring s 0 (match-beginning ng))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11489 new
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11490 (substring s (match-end ng))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11491 s))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11492
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11493 (defun org-recenter-calendar (date)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11494 "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
11495 (let* ((win (selected-window))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11496 (cwin (get-buffer-window "*Calendar*" t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11497 (calendar-move-hook nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11498 (when cwin
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11499 (select-window cwin)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11500 (calendar-goto-date (if (listp date) date
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11501 (calendar-gregorian-from-absolute date)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11502 (select-window win))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11503
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11504 (defun org-goto-calendar (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11505 "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
11506 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
11507 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
11508 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11509 (let ((tsr org-ts-regexp) diff
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11510 (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
11511 (calendar-view-holidays-initially-flag nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11512 (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
11513 (calendar-view-diary-initially-flag nil)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11514 (view-diary-entries-initially nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11515 (if (or (org-at-timestamp-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11516 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11517 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11518 (looking-at (concat ".*" tsr))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11519 (let ((d1 (time-to-days (current-time)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11520 (d2 (time-to-days
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11521 (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
11522 (setq diff (- d2 d1))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11523 (calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11524 (calendar-goto-today)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11525 (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
11526
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11527 (defun org-get-date-from-calendar ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11528 "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
11529 (with-current-buffer "*Calendar*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11530 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11531 (calendar-cursor-to-date))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11532
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11533 (defun org-date-from-calendar ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11534 "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
11535 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
11536 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11537 (if (org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11538 (org-timestamp-change 0 'calendar)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11539 (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
11540 (org-insert-time-stamp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11541 (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
11542
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11543 (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
11544 "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
11545 (let ((h (/ m 60)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11546 (setq m (- m (* 60 h)))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
11547 (format org-time-clocksum-format h m)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11548
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11549 (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
11550 "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
11551 (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
11552 (+ (* (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
11553 (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
11554 0))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11555
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11556 ;;;; Agenda files
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11557
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11558 ;;;###autoload
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11559 (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
11560 "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
11561 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
11562 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
11563
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11564 Due to some yet unresolved reason, the global function
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11565 `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
11566 (interactive "P")
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11567 (require 'iswitchb)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11568 (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
11569 (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
11570 (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
11571 ((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
11572 (t (org-buffer-list))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11573 (unwind-protect
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11574 (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
11575 (lambda ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11576 (setq iswitchb-temp-buflist
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11577 (mapcar 'buffer-name blist)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11578 (switch-to-buffer
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11579 (iswitchb-read-buffer
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11580 "Switch-to: " nil t))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11581 (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
11582
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11583 (defun org-buffer-list (&optional predicate exclude-tmp)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11584 "Return a list of Org buffers.
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11585 PREDICATE can be `export', `files' or `agenda'.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11586
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11587 export restrict the list to Export buffers.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11588 files restrict the list to buffers visiting Org files.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11589 agenda restrict the list to buffers visiting agenda files.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11590
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11591 If EXCLUDE-TMP is non-nil, ignore temporary buffers."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11592 (let* ((bfn nil)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11593 (agenda-files (and (eq predicate 'agenda)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11594 (mapcar 'file-truename (org-agenda-files t))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11595 (filter
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11596 (cond
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11597 ((eq predicate 'files)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11598 (lambda (b) (with-current-buffer b (eq major-mode 'org-mode))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11599 ((eq predicate 'export)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11600 (lambda (b) (string-match "\*Org .*Export" (buffer-name b))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11601 ((eq predicate 'agenda)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11602 (lambda (b)
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11603 (with-current-buffer b
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11604 (and (eq major-mode 'org-mode)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11605 (setq bfn (buffer-file-name b))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11606 (member (file-truename bfn) agenda-files)))))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11607 (t (lambda (b) (with-current-buffer b
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11608 (or (eq major-mode 'org-mode)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11609 (string-match "\*Org .*Export"
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11610 (buffer-name b)))))))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11611 (delq nil
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11612 (mapcar
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11613 (lambda(b)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11614 (if (and (funcall filter b)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11615 (or (not exclude-tmp)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11616 (not (string-match "tmp" (buffer-name b)))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11617 b
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11618 nil))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11619 (buffer-list)))))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11620
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
11621 (defun org-agenda-files (&optional unrestricted archives)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11622 "Get the list of agenda files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11623 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
11624 is currently in place.
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
11625 When ARCHIVES is t, include all archive files hat are really being
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
11626 used by the agenda files. If ARCHIVE is `ifmode', do this only if
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
11627 `org-agenda-archives-mode' is t."
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11628 (let ((files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11629 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11630 ((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
11631 ((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
11632 ((listp org-agenda-files) org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11633 (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
11634 (setq files (apply 'append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11635 (mapcar (lambda (f)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11636 (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
11637 (directory-files
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11638 f t org-agenda-file-regexp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11639 (list f)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11640 files)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11641 (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
11642 (setq files (delq nil
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11643 (mapcar (function
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11644 (lambda (file)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11645 (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
11646 files))))
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
11647 (when (or (eq archives t)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
11648 (and (eq archives 'ifmode) (eq org-agenda-archives-mode t)))
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
11649 (setq files (org-add-archive-files files)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11650 files))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11651
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11652 (defun org-edit-agenda-file-list ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11653 "Edit the list of agenda files.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11654 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
11655 `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
11656 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
11657 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
11658 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11659 (if (stringp org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11660 (let ((cw (current-window-configuration)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11661 (find-file org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11662 (org-set-local 'org-window-configuration cw)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11663 (org-add-hook 'after-save-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11664 (lambda ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11665 (set-window-configuration
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11666 (prog1 org-window-configuration
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11667 (kill-buffer (current-buffer))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11668 (org-install-agenda-files-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11669 (message "New agenda file list installed"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11670 nil 'local)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11671 (message "%s" (substitute-command-keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11672 "Edit list and finish with \\[save-buffer]")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11673 (customize-variable 'org-agenda-files)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11674
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11675 (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
11676 "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
11677 (if (stringp org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11678 (let ((f org-agenda-files) b)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11679 (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
11680 (with-temp-file f
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11681 (insert (mapconcat 'identity list "\n") "\n")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11682 (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
11683 (setq org-agenda-files list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11684 (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
11685
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11686 (defun org-read-agenda-file-list ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11687 "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
11688 (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
11689 (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
11690 (when (stringp org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11691 (with-temp-buffer
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11692 (insert-file-contents org-agenda-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11693 (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
11694
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11695
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11696 ;;;###autoload
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11697 (defun org-cycle-agenda-files ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11698 "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
11699 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
11700 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
11701 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11702 (let* ((fs (org-agenda-files t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11703 (files (append fs (list (car fs))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11704 (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
11705 file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11706 (unless files (error "No agenda files"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11707 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11708 (while (setq file (pop files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11709 (if (equal (file-truename file) tcf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11710 (when (car files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11711 (find-file (car files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11712 (throw 'exit t))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11713 (find-file (car fs)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11714 (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
11715
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11716 (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
11717 "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
11718 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
11719 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
11720 end of the list."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11721 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11722 (let ((org-agenda-skip-unavailable-files nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11723 (file-alist (mapcar (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11724 (cons (file-truename x) x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11725 (org-agenda-files t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11726 (ctf (file-truename buffer-file-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11727 x had)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11728 (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
11729
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11730 (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
11731 (if to-end
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11732 (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
11733 (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
11734 (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
11735 (org-install-agenda-files-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11736 (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
11737 (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
11738
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11739 (defun org-remove-file (&optional file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11740 "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
11741 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
11742 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
11743 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11744 (let* ((org-agenda-skip-unavailable-files nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11745 (file (or file buffer-file-name))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11746 (true-file (file-truename file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11747 (afile (abbreviate-file-name file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11748 (files (delq nil (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11749 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11750 (if (equal true-file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11751 (file-truename x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11752 nil x))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11753 (org-agenda-files t)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11754 (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
11755 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11756 (org-store-new-agenda-file-list files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11757 (org-install-agenda-files-menu)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11758 (message "Removed file: %s" afile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11759 (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
11760
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11761 (defun org-file-menu-entry (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11762 (vector file (list 'find-file file) t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11763
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11764 (defun org-check-agenda-file (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11765 "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
11766 (when (not (file-exists-p file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11767 (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
11768 (abbreviate-file-name file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11769 (let ((r (downcase (read-char-exclusive))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11770 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11771 ((equal r ?r)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11772 (org-remove-file file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11773 (throw 'nextfile t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11774 (t (error "Abort"))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11775
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11776 (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
11777 "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
11778 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
11779 (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
11780 (if buf
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11781 buf ; just return it
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11782 ;; 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
11783 (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
11784 (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
11785 buf)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11786
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11787 (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
11788 "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
11789 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
11790 \(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
11791 (let (buf file)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11792 (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
11793 (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
11794 (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
11795 file
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
11796 (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
11797 (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
11798 (kill-buffer buf))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11799
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11800 (defun org-prepare-agenda-buffers (files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11801 "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
11802 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11803 (let ((pa '(:org-archived t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11804 (pc '(:org-comment t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11805 (pall '(:org-archived t :org-comment t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11806 (inhibit-read-only t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11807 (rea (concat ":" org-archive-tag ":"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11808 bmp file re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11809 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11810 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11811 (while (setq file (pop files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11812 (if (bufferp file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11813 (set-buffer file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11814 (org-check-agenda-file file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11815 (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
11816 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11817 (setq bmp (buffer-modified-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11818 (org-refresh-category-properties)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11819 (setq org-todo-keywords-for-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11820 (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
11821 (setq org-done-keywords-for-agenda
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11822 (append org-done-keywords-for-agenda org-done-keywords))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11823 (setq org-todo-keyword-alist-for-agenda
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11824 (append org-todo-keyword-alist-for-agenda org-todo-key-alist))
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
11825 (setq org-tag-alist-for-agenda
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11826 (append org-tag-alist-for-agenda org-tag-alist))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11827
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11828 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11829 (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
11830 (when org-agenda-skip-archived-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11831 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11832 (while (re-search-forward rea nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11833 (if (org-on-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11834 (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
11835 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11836 (setq re (concat "^\\*+ +" org-comment-string "\\>"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11837 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11838 (add-text-properties
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11839 (match-beginning 0) (org-end-of-subtree t) pc)))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11840 (set-buffer-modified-p bmp))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11841 (setq org-todo-keyword-alist-for-agenda
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11842 (org-uniquify org-todo-keyword-alist-for-agenda)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
11843 org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11844
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11845 ;;;; Embedded LaTeX
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11846
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11847 (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
11848 "Keymap for the minor `org-cdlatex-mode'.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11849
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11850 (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
11851 (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
11852 (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
11853 (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
11854 (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
11855
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11856 (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
11857 "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
11858
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11859 (define-minor-mode org-cdlatex-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11860 "Toggle the minor `org-cdlatex-mode'.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11861 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
11862 in Org-mode.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11863 \\{org-cdlatex-mode-map}"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11864 nil " OCDL" nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11865 (when org-cdlatex-mode (require 'cdlatex))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11866 (unless org-cdlatex-texmathp-advice-is-done
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11867 (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
11868 (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
11869 "Always return t in org-mode buffers.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11870 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
11871 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
11872 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
11873 \\[org-cdlatex-mode-map]"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11874 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11875 (let (p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11876 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11877 ((not (org-mode-p)) ad-do-it)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11878 ((eq this-command 'cdlatex-math-symbol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11879 (setq ad-return-value t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11880 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
11881 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11882 (let ((p (org-inside-LaTeX-fragment-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11883 (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
11884 (setq ad-return-value t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11885 texmathp-why '("Org-mode embedded math" . 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11886 (if p ad-do-it)))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11887
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11888 (defun turn-on-org-cdlatex ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11889 "Unconditionally turn on `org-cdlatex-mode'."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11890 (org-cdlatex-mode 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11891
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11892 (defun org-inside-LaTeX-fragment-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11893 "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
11894 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
11895 sequence appearing also before point.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11896 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
11897 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
11898 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
11899 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
11900 and the position of this delimiter.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11901
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11902 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
11903 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
11904 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
11905 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
11906 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
11907 looks only before point, not after."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11908 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11909 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11910 (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
11911 (lim (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11912 (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
11913 (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11914 dd-on str (start 0) m re)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11915 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11916 (when dodollar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11917 (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
11918 re (nth 1 (assoc "$" org-latex-regexps)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11919 (while (string-match re str start)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11920 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11921 ((= (match-end 0) (length str))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11922 (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
11923 ((= (match-end 0) (- (length str) 5))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11924 (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11925 (t (setq start (match-end 0))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11926 (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
11927 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11928 (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
11929 (and (match-beginning 2) (throw 'exit nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11930 ;; count $$
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11931 (while (re-search-backward "\\$\\$" lim t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11932 (setq dd-on (not dd-on)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11933 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11934 (if dd-on (cons "$$" m))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11935
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11936
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11937 (defun org-try-cdlatex-tab ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11938 "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
11939 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
11940 - inside a LaTeX fragment, or
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11941 - 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
11942 insert a LaTeX environment."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11943 (when org-cdlatex-mode
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11944 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11945 ((save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11946 (skip-chars-backward "a-zA-Z0-9*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11947 (skip-chars-backward " \t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11948 (bolp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11949 (cdlatex-tab) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11950 ((org-inside-LaTeX-fragment-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11951 (cdlatex-tab) t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11952 (t nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11953
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11954 (defun org-cdlatex-underscore-caret (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11955 "Execute `cdlatex-sub-superscript' in LaTeX fragments.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11956 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
11957 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11958 (if (org-inside-LaTeX-fragment-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11959 (call-interactively 'cdlatex-sub-superscript)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11960 (let (org-cdlatex-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11961 (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
11962
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11963 (defun org-cdlatex-math-modify (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11964 "Execute `cdlatex-math-modify' in LaTeX fragments.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11965 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
11966 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11967 (if (org-inside-LaTeX-fragment-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11968 (call-interactively 'cdlatex-math-modify)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11969 (let (org-cdlatex-mode)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11970 (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
11971
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11972 (defvar org-latex-fragment-image-overlays nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11973 "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
11974 (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
11975
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11976 (defun org-remove-latex-fragment-image-overlays ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11977 "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
11978 (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
11979 (setq org-latex-fragment-image-overlays nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11980
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11981 (defun org-preview-latex-fragment (&optional subtree)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11982 "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
11983 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
11984 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
11985 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
11986 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
11987 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
11988 display all fragments in the buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11989 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
11990 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11991 (org-remove-latex-fragment-image-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11992 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11993 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11994 (let (beg end at msg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11995 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11996 ((or (equal subtree '(16))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11997 (not (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11998 (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
11999 (setq beg (point-min) end (point-max)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12000 msg "Creating images for buffer...%s"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12001 ((equal subtree '(4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12002 (org-back-to-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12003 (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
12004 msg "Creating images for subtree...%s"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12005 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12006 (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
12007 (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
12008 (org-back-to-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12009 (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
12010 msg (if at "Creating image...%s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12011 "Creating images for entry...%s"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12012 (message msg "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12013 (narrow-to-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12014 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12015 (org-format-latex
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12016 (concat "ltxpng/" (file-name-sans-extension
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12017 (file-name-nondirectory
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12018 buffer-file-name)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12019 default-directory 'overlays msg at 'forbuffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12020 (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
12021
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12022 (defvar org-latex-regexps
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12023 '(("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
12024 ;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ \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
12025 ;; \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
12026 ("$" "\\([^$]\\)\\(\\(\\$\\([^ \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
12027 ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12028 ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12029 ("$$" "\\$\\$[^\000]*?\\$\\$" 0 t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12030 "Regular expressions for matching embedded LaTeX.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12031
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12032 (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
12033 "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
12034 (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
12035 (let* ((prefixnodir (file-name-nondirectory prefix))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12036 (absprefix (expand-file-name prefix dir))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12037 (todir (file-name-directory absprefix))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12038 (opt org-format-latex-options)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12039 (matchers (plist-get opt :matchers))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12040 (re-list org-latex-regexps)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12041 (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
12042 m n block linkfile movefile ov)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12043 ;; 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
12044 (when (file-directory-p todir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12045 (mapc 'delete-file
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12046 (directory-files
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12047 todir 'full
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12048 (concat (regexp-quote prefixnodir) "_[0-9]+\\.png$"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12049 ;; Check the different regular expressions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12050 (while (setq e (pop re-list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12051 (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
12052 block (if (nth 3 e) "\n\n" ""))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12053 (when (member m matchers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12054 (goto-char (point-min))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12055 (while (re-search-forward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12056 (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
12057 (setq txt (match-string n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12058 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
12059 cnt (1+ cnt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12060 linkfile (format "%s_%04d.png" prefix cnt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12061 movefile (format "%s_%04d.png" absprefix cnt)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12062 link (concat block "[[file:" linkfile "]]" block))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12063 (if msg (message msg cnt))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12064 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12065 (unless checkdir ; make sure the directory exists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12066 (setq checkdir t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12067 (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
12068 (org-create-formula-image
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12069 txt movefile opt forbuffer)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12070 (if overlays
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12071 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12072 (setq ov (org-make-overlay beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12073 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12074 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12075 (org-overlay-put ov 'invisible t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12076 (org-overlay-put
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12077 ov 'end-glyph
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12078 (make-glyph (vector 'png :file movefile))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12079 (org-overlay-put
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12080 ov 'display
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12081 (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
12082 (push ov org-latex-fragment-image-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12083 (goto-char end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12084 (delete-region beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12085 (insert link))))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12086
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12087 ;; 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
12088 (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
12089 (let* ((tmpdir (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12090 (temp-directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12091 temporary-file-directory))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12092 (texfilebase (make-temp-name
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12093 (expand-file-name "orgtex" tmpdir)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12094 (texfile (concat texfilebase ".tex"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12095 (dvifile (concat texfilebase ".dvi"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12096 (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
12097 (fnh (if (featurep 'xemacs)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12098 (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
12099 (face-attribute 'default :height nil)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12100 (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
12101 (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
12102 (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
12103 "Black"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12104 (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
12105 "Transparent")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12106 (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
12107 (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
12108 (with-temp-file texfile
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12109 (insert org-format-latex-header
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12110 "\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
12111 (let ((dir default-directory))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12112 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12113 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12114 (cd tmpdir)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12115 (call-process "latex" nil nil nil texfile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12116 (error nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12117 (cd dir))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12118 (if (not (file-exists-p dvifile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12119 (progn (message "Failed to create dvi file from %s" texfile) nil)
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12120 (condition-case nil
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12121 (call-process "dvipng" nil nil nil
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12122 "-E" "-fg" fg "-bg" bg
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12123 "-D" dpi
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12124 ;;"-x" scale "-y" scale
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12125 "-T" "tight"
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12126 "-o" pngfile
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12127 dvifile)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12128 (error nil))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12129 (if (not (file-exists-p pngfile))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12130 (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
12131 ;; 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
12132 (copy-file pngfile tofile 'replace)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12133 (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
12134 (delete-file (concat texfilebase e)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12135 pngfile))))
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 (defun org-dvipng-color (attr)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12138 "Return an rgb color specification for dvipng."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12139 (apply 'format "rgb %s %s %s"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12140 (mapcar 'org-normalize-color
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12141 (color-values (face-attribute 'default attr nil)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12142
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12143 (defun org-normalize-color (value)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12144 "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
12145 (format "%g" (/ value 65535.0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12146
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 ;;;; Key bindings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12149
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12150 ;; 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
12151 (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
12152
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12153 ;; TAB key with modifiers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12154 (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
12155 (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
12156 (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
12157 (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
12158 (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
12159 (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
12160 ;; 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
12161 (unless (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12162 (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
12163 (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
12164 (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
12165
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12166 (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
12167 (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
12168 (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
12169
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12170 ;; Cursor keys with modifiers
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12171 (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
12172 (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
12173 (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
12174 (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
12175
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12176 (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
12177 (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
12178 (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
12179 (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
12180
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12181 (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
12182 (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
12183 (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
12184 (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
12185
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12186 (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
12187 (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
12188
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12189 ;;; Extra keys for tty access.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12190 ;; 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
12191 ;; menus don't show the simple keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12192
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
12193 (when (or org-use-extra-keys
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
12194 (featurep 'xemacs) ;; because XEmacs supports multi-device stuff
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12195 (not window-system))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12196 (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
12197 (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
12198 (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
12199 (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
12200 (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
12201 (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
12202 (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
12203 (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
12204 (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
12205 (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
12206 (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
12207 (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
12208 (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
12209 (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
12210 (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
12211 (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
12212 (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
12213 (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
12214 (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
12215 (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
12216 (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
12217 (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
12218
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12219 ;; All the other keys
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12220
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12221 (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
12222 (org-defkey org-mode-map "\C-c\C-r" 'org-reveal)
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12223 (if (boundp 'narrow-map)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12224 (org-defkey narrow-map "s" 'org-narrow-to-subtree)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
12225 (org-defkey org-mode-map "\C-xns" 'org-narrow-to-subtree))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12226 (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
12227 (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
12228 (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
12229 (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
12230 (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
12231 (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
12232 (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
12233 (org-defkey org-mode-map "\C-c\C-t" 'org-todo)
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
12234 (org-defkey org-mode-map "\C-c\C-q" 'org-set-tags-command)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12235 (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
12236 (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
12237 (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
12238 (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
12239 (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
12240 (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
12241 (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
12242 (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
12243 (org-defkey org-mode-map "\M-\C-m" 'org-insert-heading)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
12244 (org-defkey org-mode-map [(control return)] 'org-insert-heading-respect-content)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
12245 (org-defkey org-mode-map [(shift control return)] 'org-insert-todo-heading-respect-content)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12246 (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
12247 (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
12248 (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
12249 (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
12250 (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
12251 (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
12252 (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
12253 (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
12254 (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
12255 (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
12256 (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
12257 (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
12258 (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
12259 (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
12260 (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
12261 (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
12262 (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
12263 (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
12264 (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
12265 (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
12266 (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
12267 (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
12268 (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
12269 (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
12270 (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
12271 (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
12272 (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
12273 (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
12274 (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
12275 (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
12276 (org-defkey org-mode-map "\C-c=" 'org-table-eval-formula)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12277 (org-defkey org-mode-map "\C-c'" 'org-edit-special)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12278 (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
12279 (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
12280 (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
12281 (org-defkey org-mode-map "\C-c~" 'org-table-create-with-table.el)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
12282 (org-defkey org-mode-map "\C-c\C-a" 'org-attach)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12283 (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
12284 (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
12285 (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
12286 (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
12287 (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
12288
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12289 (org-defkey org-mode-map "\C-c\C-x\C-k" 'org-mark-entry-for-agenda-action)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12290 (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
12291 (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
12292 (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
12293
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12294 (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
12295 (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
12296 (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
12297 (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
12298 (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
12299 (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
12300 (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
12301 (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
12302 (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
12303 (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
12304 (org-defkey org-mode-map "\C-c\C-xp" 'org-set-property)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
12305 (org-defkey org-mode-map "\C-c\C-xi" 'org-insert-columns-dblock)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12306
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12307 (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
12308
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12309 (when (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12310 (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
12311
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12312 (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
12313 (defun org-self-insert-command (N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12314 "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
12315 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
12316 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
12317 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12318 (if (and (org-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12319 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12320 ;; 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
12321 (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
12322 (member last-command
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12323 '(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
12324 (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
12325 ;; 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
12326 (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
12327 ;; 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
12328 (org-table-blank-field)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12329 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12330 (eq N 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12331 (looking-at "[^|\n]* |"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12332 (let (org-table-may-need-update)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12333 (goto-char (1- (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12334 (delete-backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12335 (goto-char (match-beginning 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12336 (self-insert-command N))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12337 (setq org-table-may-need-update t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12338 (self-insert-command N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12339 (org-fix-tags-on-the-fly)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12340
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12341 (defun org-fix-tags-on-the-fly ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12342 (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
12343 (org-on-heading-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12344 (org-align-tags-here org-tags-column)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12345
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12346 (defun org-delete-backward-char (N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12347 "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
12348 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
12349 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
12350 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
12351 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
12352 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12353 (if (and (org-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12354 (eq N 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12355 (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
12356 (looking-at ".*?|"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12357 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12358 (noalign (looking-at "[^|\n\r]* |"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12359 (c org-table-may-need-update))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12360 (backward-delete-char N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12361 (skip-chars-forward "^|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12362 (insert " ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12363 (goto-char (1- pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12364 ;; 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
12365 ;; 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
12366 (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
12367 (backward-delete-char N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12368 (org-fix-tags-on-the-fly)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12369
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12370 (defun org-delete-char (N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12371 "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
12372 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
12373 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
12374 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
12375 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
12376 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12377 (if (and (org-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12378 (not (bolp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12379 (not (= (char-after) ?|))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12380 (eq N 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12381 (if (looking-at ".*?|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12382 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12383 (noalign (looking-at "[^|\n\r]* |"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12384 (c org-table-may-need-update))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12385 (replace-match (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12386 (substring (match-string 0) 1 -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12387 " |"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12388 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12389 ;; 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
12390 ;; 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
12391 (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
12392 (delete-char N))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12393 (delete-char N)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12394 (org-fix-tags-on-the-fly)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12395
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12396 ;; 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
12397 (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
12398 (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
12399 (put 'org-delete-char 'delete-selection 'supersede)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12400 (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
12401
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12402 ;; Make `flyspell-mode' delay after some commands
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12403 (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
12404 (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
12405 (put 'org-delete-char 'flyspell-delayed t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12406 (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
12407
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12408 ;; 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
12409 (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
12410 (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
12411
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12412 ;; 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
12413 ;; 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
12414
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12415 (defun org-remap (map &rest commands)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12416 "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
12417 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
12418 (let (new old)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12419 (while commands
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12420 (setq old (pop commands) new (pop commands))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12421 (if (fboundp 'command-remapping)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12422 (org-defkey map (vector 'remap old) new)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12423 (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
12424
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12425 (when (eq org-enable-table-editor 'optimized)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12426 ;; 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
12427 ;; some standard editing functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12428 (org-remap org-mode-map
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12429 'self-insert-command 'org-self-insert-command
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12430 'delete-char 'org-delete-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12431 'delete-backward-char 'org-delete-backward-char)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12432 (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
12433
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12434 (defun org-shiftcursor-error ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12435 "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
12436 (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
12437
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12438 (defun org-shifttab (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12439 "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
12440 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
12441 on context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12442 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12443 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12444 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12445 ((org-at-table-p) (call-interactively 'org-table-previous-field))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12446 ((integerp arg)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12447 (message "Content view to level: %d" arg)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12448 (org-content (prefix-numeric-value arg))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12449 (setq org-cycle-global-status 'overview))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12450 (t (call-interactively 'org-global-cycle))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12451
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12452 (defun org-shiftmetaleft ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12453 "Promote subtree or delete table column.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12454 Calls `org-promote-subtree', `org-outdent-item',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12455 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
12456 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12457 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12458 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12459 ((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
12460 ((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
12461 ((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
12462 (t (org-shiftcursor-error))))
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 (defun org-shiftmetaright ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12465 "Demote subtree or insert table column.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12466 Calls `org-demote-subtree', `org-indent-item',
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12467 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
12468 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12469 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12470 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12471 ((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
12472 ((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
12473 ((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
12474 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12475
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12476 (defun org-shiftmetaup (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12477 "Move subtree up or kill table row.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12478 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
12479 `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
12480 for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12481 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12482 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12483 ((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
12484 ((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
12485 ((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
12486 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12487 (defun org-shiftmetadown (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12488 "Move subtree down or insert table row.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12489 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
12490 `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
12491 commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12492 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12493 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12494 ((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
12495 ((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
12496 ((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
12497 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12498
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12499 (defun org-metaleft (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12500 "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
12501 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
12502 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
12503 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12504 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12505 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12506 ((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
12507 ((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
12508 (call-interactively 'org-do-promote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12509 ((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
12510 (t (call-interactively 'backward-word))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12511
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12512 (defun org-metaright (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12513 "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
12514 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
12515 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
12516 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12517 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12518 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12519 ((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
12520 ((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
12521 (call-interactively 'org-do-demote))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12522 ((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
12523 (t (call-interactively 'forward-word))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12524
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12525 (defun org-metaup (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12526 "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
12527 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
12528 `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
12529 for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12530 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12531 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12532 ((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
12533 ((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
12534 ((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
12535 (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
12536
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12537 (defun org-metadown (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12538 "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
12539 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
12540 `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
12541 commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12542 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12543 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12544 ((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
12545 ((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
12546 ((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
12547 (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
12548
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12549 (defun org-shiftup (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12550 "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
12551 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
12552 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
12553 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12554 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12555 ((org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12556 (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
12557 'org-timestamp-down 'org-timestamp-up)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12558 ((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
12559 ((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
12560 ((org-clocktable-try-shift 'up arg))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12561 (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
12562
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12563 (defun org-shiftdown (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12564 "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
12565 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
12566 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
12567 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12568 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12569 ((org-at-timestamp-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12570 (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
12571 'org-timestamp-up 'org-timestamp-down)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12572 ((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
12573 ((org-clocktable-try-shift 'down arg))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12574 (t (call-interactively 'org-next-item))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12575
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12576 (defun org-shiftright (&optional arg)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12577 "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
12578 (interactive "P")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12579 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12580 ((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
12581 ((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
12582 ((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
12583 ((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
12584 ((org-clocktable-try-shift 'right arg))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12585 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12586
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12587 (defun org-shiftleft (&optional arg)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12588 "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
12589 (interactive "P")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12590 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12591 ((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
12592 ((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
12593 ((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
12594 ((org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12595 (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
12596 ((org-clocktable-try-shift 'left arg))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12597 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12598
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12599 (defun org-shiftcontrolright ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12600 "Switch to next TODO set."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12601 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12602 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12603 ((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
12604 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12605
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12606 (defun org-shiftcontrolleft ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12607 "Switch to previous TODO set."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12608 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12609 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12610 ((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
12611 (t (org-shiftcursor-error))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12612
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12613 (defun org-ctrl-c-ret ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12614 "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
12615 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12616 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12617 ((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
12618 (t (call-interactively 'org-insert-heading))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12619
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12620 (defun org-copy-special ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12621 "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
12622 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
12623 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12624 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12625 (call-interactively
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12626 (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
12627
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12628 (defun org-cut-special ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12629 "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
12630 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
12631 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12632 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12633 (call-interactively
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12634 (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
12635
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12636 (defun org-paste-special (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12637 "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
12638 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
12639 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12640 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12641 (if (org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12642 (org-table-paste-rectangle)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12643 (org-paste-subtree arg)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12644
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12645 (defun org-edit-special ()
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12646 "Call a special editor for the stuff at point.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12647 When at a table, call the formula editor with `org-table-edit-formulas'.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12648 When at the first line of an src example, call `org-edit-src-code'.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12649 When in an #+include line, visit the include file. Otherwise call
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12650 `ffap' to visit the file at point."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12651 (interactive)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12652 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12653 ((org-at-table-p)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12654 (call-interactively 'org-table-edit-formulas))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12655 ((save-excursion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12656 (beginning-of-line 1)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12657 (looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12658 (find-file (org-trim (match-string 1))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12659 ((org-edit-src-code))
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
12660 ((org-edit-fixed-width-region))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12661 (t (call-interactively 'ffap))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12662
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12663 (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
12664 "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
12665
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12666 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
12667
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12668 - 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
12669 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
12670 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
12671
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12672 - 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
12673 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
12674 information.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12675
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12676 - 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
12677 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
12678
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12679 - 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
12680 the entire table.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12681
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12682 - 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
12683
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12684 - 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
12685 activate that table.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12686
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
12687 - If the current buffer is a remember buffer, close note and file
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
12688 it. A prefix argument of 1 files to the default location
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
12689 without further interaction. A prefix argument of 2 files to
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
12690 the currently clocking task.
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12691
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12692 - 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
12693 links in this buffer.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12694
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12695 - 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
12696 ordered list.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12697
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12698 - 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
12699 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12700 (let ((org-enable-table-editor t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12701 (cond
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12702 ((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
12703 org-occur-highlights
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12704 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
12705 (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
12706 (org-remove-occur-highlights)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12707 (org-remove-latex-fragment-image-overlays)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12708 (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
12709 ((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
12710 (fboundp org-finish-function))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12711 (funcall org-finish-function))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12712 ((org-at-property-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12713 (call-interactively 'org-property-action))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12714 ((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
12715 ((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
12716 ((org-at-table.el-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12717 (require 'table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12718 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12719 (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
12720 (call-interactively 'table-recognize-table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12721 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12722 (org-table-maybe-eval-formula)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12723 (if arg
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12724 (call-interactively 'org-table-recalculate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12725 (org-table-maybe-recalculate-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12726 (call-interactively 'org-table-align))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12727 ((org-at-item-checkbox-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12728 (call-interactively 'org-toggle-checkbox))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12729 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12730 (call-interactively 'org-maybe-renumber-ordered-list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12731 ((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
12732 ;; Dynamic block
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12733 (beginning-of-line 1)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
12734 (save-excursion (org-update-dblock)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12735 ((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
12736 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12737 ((equal (match-string 1) "TBLFM")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12738 ;; Recalculate the table before this line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12739 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12740 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12741 (skip-chars-backward " \r\n\t")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12742 (if (org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12743 (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
12744 (t
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12745 ; (org-set-regexps-and-options)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12746 ; (org-restart-font-lock)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12747 (let ((org-inhibit-startup t)) (org-mode-restart))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12748 (message "Local setup has been refreshed"))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12749 (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
12750
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12751 (defun org-mode-restart ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12752 "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
12753 Also updates the keyword regular expressions."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12754 (interactive)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12755 (org-mode)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12756 (message "Org-mode restarted"))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12757
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12758 (defun org-kill-note-or-show-branches ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12759 "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
12760 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12761 (if (not org-finish-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12762 (call-interactively 'show-branches)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12763 (let ((org-note-abort t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12764 (funcall org-finish-function))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12765
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12766 (defun org-return (&optional indent)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12767 "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
12768 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
12769 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12770 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12771 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12772 ((bobp) (if indent (newline-and-indent) (newline)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12773 ((and (org-at-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12774 (looking-at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12775 (org-re "\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12776 (org-show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12777 (end-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12778 (newline))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12779 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12780 (org-table-justify-field-maybe)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12781 (call-interactively 'org-table-next-row))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12782 (t (if indent (newline-and-indent) (newline)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12783
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12784 (defun org-return-indent ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12785 "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
12786 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
12787 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
12788 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12789 (org-return t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12790
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12791 (defun org-ctrl-c-star ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12792 "Compute table, or change heading status of lines.
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12793 Calls `org-table-recalculate' or `org-toggle-region-headings',
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12794 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
12795 line into a subheading."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12796 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12797 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12798 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12799 (call-interactively 'org-table-recalculate))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12800 ((org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12801 ;; 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
12802 (call-interactively 'org-toggle-region-headings))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12803 ((org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12804 (org-toggle-region-headings (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12805 (min (1+ (point-at-eol)) (point-max))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12806 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12807 ;; Convert to heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12808 (let ((level (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12809 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12810 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12811 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12812 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12813 (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12814 (error 0))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12815 (replace-match
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12816 (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
12817 (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
12818 (min (1+ (point-at-eol)) (point-max))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12819
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12820 (defun org-ctrl-c-minus ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12821 "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
12822 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
12823 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
12824 `org-cycle-list-bullet', depending on context."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12825 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12826 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12827 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12828 (call-interactively 'org-table-insert-hline))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12829 ((org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12830 ;; Convert to item
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12831 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12832 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12833 (if (looking-at "\\*+ ")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12834 (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
12835 ((org-region-active-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12836 ;; 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
12837 (call-interactively 'org-toggle-region-items))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12838 ((org-in-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12839 (call-interactively 'org-cycle-list-bullet))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12840 (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
12841 (min (1+ (point-at-eol)) (point-max))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12842
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12843 (defun org-toggle-region-items (beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12844 "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
12845 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
12846 to normal lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12847 (interactive "r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12848 (let (l2 l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12849 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12850 (goto-char end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12851 (setq l2 (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12852 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12853 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12854 (setq l (1- (org-current-line)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12855 (if (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12856 ;; We already have items, de-itemize
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12857 (while (< (setq l (1+ l)) l2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12858 (when (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12859 (goto-char (match-beginning 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12860 (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
12861 (and (looking-at "[ \t]+") (replace-match "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12862 (beginning-of-line 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12863 (while (< (setq l (1+ l)) l2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12864 (unless (org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12865 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12866 (replace-match "\\1- \\2")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12867 (beginning-of-line 2))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12868
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12869 (defun org-toggle-region-headings (beg end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12870 "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
12871 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
12872 to normal lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12873 (interactive "r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12874 (let (l2 l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12875 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12876 (goto-char end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12877 (setq l2 (org-current-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12878 (goto-char beg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12879 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12880 (setq l (1- (org-current-line)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12881 (if (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12882 ;; We already have headlines, de-star them
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12883 (while (< (setq l (1+ l)) l2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12884 (when (org-on-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12885 (and (looking-at outline-regexp) (replace-match "")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12886 (beginning-of-line 2))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12887 (let* ((stars (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12888 (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
12889 (or (match-string 1) "*")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12890 (add-stars (if org-odd-levels-only "**" "*"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12891 (rpl (concat stars add-stars " \\2")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12892 (while (< (setq l (1+ l)) l2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12893 (unless (org-on-heading-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12894 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12895 (replace-match rpl)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12896 (beginning-of-line 2)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12897
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12898 (defun org-meta-return (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12899 "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
12900 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
12901 See the individual commands for more information."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12902 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12903 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12904 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12905 (call-interactively 'org-table-wrap-region))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12906 (t (call-interactively 'org-insert-heading))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12907
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12908 ;;; Menu entries
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12909
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12910 ;; Define the Org-mode menus
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12911 (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
12912 '("Tbl"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12913 ["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
12914 ["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
12915 ["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
12916 ["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
12917 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12918 ["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
12919 ["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
12920 ["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
12921 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12922 ("Column"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12923 ["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
12924 ["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
12925 ["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
12926 ["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
12927 ("Row"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12928 ["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
12929 ["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
12930 ["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
12931 ["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
12932 ["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
12933 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12934 ["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
12935 ("Rectangle"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12936 ["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
12937 ["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
12938 ["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
12939 ["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
12940 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12941 ("Calculate"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12942 ["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
12943 ["Set Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="]
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
12944 ["Edit Formulas" org-edit-special (org-at-table-p)]
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12945 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12946 ["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
12947 ["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
12948 ["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
12949 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12950 ["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
12951 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12952 ["Sum Column/Rectangle" org-table-sum
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12953 (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
12954 ["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
12955 ["Debug Formulas"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12956 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
12957 :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
12958 ["Show Col/Row Numbers"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12959 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
12960 :style toggle
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12961 :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
12962 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12963 ["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
12964 org-enable-table-editor)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12965 ["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
12966 ["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
12967 ["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
12968 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12969 ["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
12970
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12971 (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
12972 '("Org"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12973 ("Show/Hide"
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
12974 ["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
12975 ["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
12976 ["Sparse Tree..." org-sparse-tree t]
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12977 ["Reveal Context" org-reveal t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12978 ["Show All" show-all t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12979 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12980 ["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
12981 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12982 ["New Heading" org-insert-heading t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12983 ("Navigate Headings"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12984 ["Up" outline-up-heading t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12985 ["Next" outline-next-visible-heading t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12986 ["Previous" outline-previous-visible-heading t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12987 ["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
12988 ["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
12989 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12990 ["Jump" org-goto t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12991 ("Edit Structure"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12992 ["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
12993 ["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
12994 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12995 ["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
12996 ["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
12997 ["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
12998 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12999 ["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
13000 ["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
13001 ["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
13002 ["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
13003 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13004 ["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
13005 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13006 ["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
13007 ["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
13008 ("Editing"
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13009 ["Emphasis..." org-emphasize t]
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13010 ["Edit Source Example" org-edit-special t])
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13011 ("Archive"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13012 ["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
13013 ; ["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
13014 ; :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
13015 ["Sparse trees open ARCHIVE trees"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13016 (setq org-sparse-tree-open-archived-trees
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13017 (not org-sparse-tree-open-archived-trees))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13018 :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
13019 ["Cycling opens ARCHIVE trees"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13020 (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
13021 :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
13022 "--"
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13023 ["Move subtree to archive sibling" org-archive-to-archive-sibling t]
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13024 ["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
13025 ; ["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
13026 ; :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
13027 )
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13028 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13029 ("TODO Lists"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13030 ["TODO/DONE/-" org-todo t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13031 ("Select keyword"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13032 ["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
13033 ["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
13034 ["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
13035 ["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
13036 ["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
13037 ["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
13038 ["Global TODO list" org-todo-list t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13039 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13040 ["Set Priority" org-priority t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13041 ["Priority Up" org-shiftup t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13042 ["Priority Down" org-shiftdown t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13043 ("TAGS and Properties"
99139
8fa7ef477c04 2008-10-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 98870
diff changeset
13044 ["Set Tags" 'org-set-tags-command t]
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13045 ["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
13046 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13047 ["Set property" 'org-set-property t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13048 ["Column view of properties" org-columns t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13049 ["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
13050 ("Dates and Scheduling"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13051 ["Timestamp" org-time-stamp t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13052 ["Timestamp (inactive)" org-time-stamp-inactive t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13053 ("Change Date"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13054 ["1 Day Later" org-shiftright t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13055 ["1 Day Earlier" org-shiftleft t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13056 ["1 ... Later" org-shiftup t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13057 ["1 ... Earlier" org-shiftdown t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13058 ["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
13059 ["Schedule Item" org-schedule t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13060 ["Deadline" org-deadline t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13061 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13062 ["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
13063 :style radio :selected org-display-custom-times]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13064 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13065 ["Goto Calendar" org-goto-calendar t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13066 ["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
13067 ("Logging work"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13068 ["Clock in" org-clock-in t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13069 ["Clock out" org-clock-out t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13070 ["Clock cancel" org-clock-cancel t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13071 ["Goto running clock" org-clock-goto t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13072 ["Display times" org-clock-display t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13073 ["Create clock table" org-clock-report t]
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 ["Record DONE time"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13076 (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
13077 (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
13078 (car org-done-keywords)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13079 (if org-log-done "automatically" "not")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13080 :style toggle :selected org-log-done])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13081 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13082 ["Agenda Command..." org-agenda t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13083 ["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
13084 ("File List for Agenda")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13085 ("Special views current file"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13086 ["TODO Tree" org-show-todo-tree t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13087 ["Check Deadlines" org-check-deadlines t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13088 ["Timeline" org-timeline t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13089 ["Tags Tree" org-tags-sparse-tree t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13090 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13091 ("Hyperlinks"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13092 ["Store Link (Global)" org-store-link t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13093 ["Insert Link" org-insert-link t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13094 ["Follow Link" org-open-at-point t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13095 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13096 ["Next link" org-next-link t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13097 ["Previous link" org-previous-link t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13098 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13099 ["Descriptive Links"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13100 (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
13101 :style radio
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13102 :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
13103 ["Literal Links"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13104 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13105 (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
13106 :style radio
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13107 :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
13108 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13109 ["Export/Publish..." org-export t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13110 ("LaTeX"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13111 ["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
13112 :selected org-cdlatex-mode]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13113 ["Insert Environment" cdlatex-environment (fboundp 'cdlatex-environment)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13114 ["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
13115 ["Modify math symbol" org-cdlatex-math-modify
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13116 (org-inside-LaTeX-fragment-p)]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13117 ["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
13118 (if (featurep 'org-exp)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13119 (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
13120 (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
13121 (require 'org-exp))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13122 :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
13123 org-export-with-LaTeX-fragments)])
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13124 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13125 ("Documentation"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13126 ["Show Version" org-version t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13127 ["Info Documentation" org-info t])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13128 ("Customize"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13129 ["Browse Org Group" org-customize t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13130 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13131 ["Expand This Menu" org-create-customize-menu
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13132 (fboundp 'customize-menu-create)])
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13133 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13134 ["Refresh setup" org-mode-restart t]
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
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13137 (defun org-info (&optional node)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13138 "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
13139 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
13140 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13141 (info (format "(org)%s" (or node ""))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13142
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13143 (defun org-install-agenda-files-menu ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13144 (let ((bl (buffer-list)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13145 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13146 (while bl
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13147 (set-buffer (pop bl))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13148 (if (org-mode-p) (setq bl nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13149 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13150 (easy-menu-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13151 '("Org") "File List for Agenda"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13152 (append
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13153 (list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13154 ["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
13155 ["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
13156 ["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
13157 ["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
13158 ["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
13159 "--")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13160 (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
13161
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13162 ;;;; Documentation
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13163
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13164 ;;;###autoload
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13165 (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
13166 (interactive)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13167 (mapc 'require
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13168 '(org-agenda org-archive org-clock org-colview
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13169 org-exp org-id org-export-latex org-publish
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13170 org-remember org-table)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13171
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13172 ;;;###autoload
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13173 (defun org-customize ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13174 "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
13175 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13176 (org-load-modules-maybe)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13177 (org-require-autoloaded-modules)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13178 (customize-browse 'org))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13179
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13180 (defun org-create-customize-menu ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13181 "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
13182 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13183 (org-load-modules-maybe)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13184 (org-require-autoloaded-modules)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13185 (if (fboundp 'customize-menu-create)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13186 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13187 (easy-menu-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13188 '("Org") "Customize"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13189 `(["Browse Org group" org-customize t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13190 "--"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13191 ,(customize-menu-create 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13192 ["Set" Custom-set t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13193 ["Save" Custom-save t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13194 ["Reset to Current" Custom-reset-current t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13195 ["Reset to Saved" Custom-reset-saved t]
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13196 ["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
13197 (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
13198 (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
13199
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13200 ;;;; Miscellaneous stuff
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13201
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13202 ;;; Generally useful functions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13203
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13204 (defun org-display-warning (message) ;; Copied from Emacs-Muse
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13205 "Display the given MESSAGE as a warning."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13206 (if (fboundp 'display-warning)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13207 (display-warning 'org message
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13208 (if (featurep 'xemacs)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13209 'warning
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13210 :warning))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13211 (let ((buf (get-buffer-create "*Org warnings*")))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13212 (with-current-buffer buf
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13213 (goto-char (point-max))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13214 (insert "Warning (Org): " message)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13215 (unless (bolp)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13216 (newline)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13217 (display-buffer buf)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13218 (sit-for 0))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13219
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13220 (defun org-goto-marker-or-bmk (marker &optional bookmark)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13221 "Go to MARKER, widen if necessary. When marker is not live, try BOOKMARK."
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13222 (if (and marker (marker-buffer marker)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13223 (buffer-live-p (marker-buffer marker)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13224 (progn
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13225 (switch-to-buffer (marker-buffer marker))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13226 (if (or (> marker (point-max)) (< marker (point-min)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13227 (widen))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13228 (goto-char marker))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13229 (if bookmark
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13230 (bookmark-jump bookmark)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13231 (error "Cannot find location"))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13232
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13233 (defun org-quote-csv-field (s)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13234 "Quote field for inclusion in CSV material."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13235 (if (string-match "[\",]" s)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13236 (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\"")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13237 s))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13238
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13239 (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
13240 "Delete PROPERTY from PLIST.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13241 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
13242 (let (p)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13243 (while plist
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13244 (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
13245 (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
13246 (setq plist (cddr plist)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13247 p))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13248
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13249 (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
13250 "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
13251 (interactive "p")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13252 (self-insert-command N))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13253
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13254 (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
13255 "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
13256 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
13257 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
13258 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
13259 (let (b l)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13260 (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
13261 (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
13262 (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
13263 'invisible 'org-link s))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13264 (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
13265 (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
13266 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
13267 (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
13268 (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
13269 (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
13270 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
13271 (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
13272 (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
13273 (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
13274 l))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13275
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13276 (defun org-get-indentation (&optional line)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13277 "Get the indentation of the current line, interpreting tabs.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13278 When LINE is given, assume it represents a line and compute its indentation."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13279 (if line
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13280 (if (string-match "^ *" (org-remove-tabs line))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13281 (match-end 0))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13282 (save-excursion
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13283 (beginning-of-line 1)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13284 (skip-chars-forward " \t")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13285 (current-column))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13286
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13287 (defun org-remove-tabs (s &optional width)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13288 "Replace tabulators in S with spaces.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13289 Assumes that s is a single line, starting in column 0."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13290 (setq width (or width tab-width))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13291 (while (string-match "\t" s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13292 (setq s (replace-match
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13293 (make-string
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13294 (- (* width (/ (+ (match-beginning 0) width) width))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13295 (match-beginning 0)) ?\ )
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13296 t t s)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13297 s)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13298
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13299 (defun org-fix-indentation (line ind)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13300 "Fix indentation in LINE.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13301 IND is a cons cell with target and minimum indentation.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13302 If the current indenation in LINE is smaller than the minimum,
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13303 leave it alone. If it is larger than ind, set it to the target."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13304 (let* ((l (org-remove-tabs line))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13305 (i (org-get-indentation l))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13306 (i1 (car ind)) (i2 (cdr ind)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13307 (if (>= i i2) (setq l (substring line i2)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13308 (if (> i1 0)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13309 (concat (make-string i1 ?\ ) l)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13310 l)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
13311
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13312 (defun org-base-buffer (buffer)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13313 "Return the base buffer of BUFFER, if it has one. Else return the buffer."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13314 (if (not buffer)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13315 buffer
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13316 (or (buffer-base-buffer buffer)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13317 buffer)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13318
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13319 (defun org-trim (s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13320 "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
13321 (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
13322 (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
13323 s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13324
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13325 (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
13326 "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
13327 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
13328 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
13329 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
13330 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
13331 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
13332 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
13333 (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
13334 (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
13335 w ll)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13336 (cond (width
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13337 (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
13338 (lines
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13339 (setq w maxword)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13340 (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
13341 (if (<= (length ll) lines)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13342 ll
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13343 (setq ll words)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13344 (while (> (length ll) lines)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13345 (setq w (1+ w))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13346 (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
13347 ll))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13348 (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
13349
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13350 (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
13351 "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
13352 (let (lines line)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13353 (while words
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13354 (setq line (pop words))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13355 (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
13356 (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
13357 (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
13358 (nreverse lines)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13359
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13360 (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
13361 "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
13362 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
13363 and end of string."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13364 (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
13365 (start 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13366 notfirst
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13367 (list nil))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13368 (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
13369 (if (and notfirst
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13370 (= start (match-beginning 0))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13371 (< start (length string)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13372 (1+ start) start))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13373 (< (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
13374 (setq notfirst t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13375 (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
13376 (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
13377 (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
13378 (setq list
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13379 (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
13380 list)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13381 (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
13382 (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
13383 (setq list
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13384 (cons (substring string start)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13385 list)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13386 (nreverse list)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13387
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13388 (defun org-context ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13389 "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
13390 If several contexts apply, all are returned.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13391 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
13392 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
13393 contexts are:
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13394
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13395 :headline anywhere in a headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13396 :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
13397 :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
13398 :tags on the TAGS in a headline
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13399 :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
13400 :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
13401 :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
13402 :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
13403 :table in an org-mode table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13404 :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
13405 :table-table in a table.el table
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13406 :link on a hyperlink
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13407 :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
13408 :target on a <<target>>
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13409 :radio-target on a <<<radio-target>>>
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13410 :latex-fragment on a LaTeX fragment
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13411 :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
13412
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13413 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
13414 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
13415 and :keyword."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13416 (let* ((f (get-text-property (point) 'face))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13417 (faces (if (listp f) f (list f)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13418 (p (point)) clist o)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13419 ;; First the large context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13420 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13421 ((org-on-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13422 (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
13423 (when (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13424 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13425 (looking-at org-todo-line-tags-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13426 (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
13427 (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
13428 (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
13429 (goto-char p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13430 (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
13431 (if (looking-at "\\[#[A-Z0-9]\\]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13432 (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
13433
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13434 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13435 (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
13436 (push (list :item (point-at-bol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13437 (save-excursion (org-end-of-item) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13438 clist)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13439 (and (org-at-item-checkbox-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13440 (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
13441
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13442 ((org-at-table-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13443 (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
13444 (if (memq 'org-formula faces)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13445 (push (list :table-special
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13446 (previous-single-property-change p 'face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13447 (next-single-property-change p 'face)) clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13448 ((org-at-table-p 'any)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13449 (push (list :table-table) clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13450 (goto-char p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13451
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13452 ;; Now the small context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13453 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13454 ((org-at-timestamp-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13455 (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
13456 ((memq 'org-link faces)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13457 (push (list :link
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13458 (previous-single-property-change p 'face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13459 (next-single-property-change p 'face)) clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13460 ((memq 'org-special-keyword faces)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13461 (push (list :keyword
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13462 (previous-single-property-change p 'face)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13463 (next-single-property-change p 'face)) clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13464 ((org-on-target-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13465 (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
13466 (goto-char (1- (match-beginning 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13467 (if (looking-at org-radio-target-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13468 (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
13469 (goto-char p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13470 ((setq o (car (delq nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13471 (mapcar
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13472 (lambda (x)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13473 (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
13474 (org-overlays-at (point))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13475 (push (list :latex-fragment
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13476 (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
13477 (push (list :latex-preview
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13478 (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
13479 ((org-inside-LaTeX-fragment-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13480 ;; FIXME: positions wrong.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13481 (push (list :latex-fragment (point) (point)) clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13482
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13483 (setq clist (nreverse (delq nil clist)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13484 clist))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13485
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13486 ;; 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
13487 (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
13488 "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
13489 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
13490 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
13491 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
13492 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
13493 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13494 (let ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13495 (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
13496 (inc (if visually 1 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13497 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13498 (beginning-of-line (- 1 (or nlines 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13499 (while (re-search-forward re eol t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13500 (if (and (<= (match-beginning 0) pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13501 (>= (+ inc (match-end 0)) pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13502 (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
13503
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13504 (defun org-at-regexp-p (regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13505 "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
13506 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13507 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13508 (let ((pos (point)) (end (point-at-eol)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13509 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13510 (while (re-search-forward regexp end t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13511 (if (and (<= (match-beginning 0) pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13512 (>= (match-end 0) pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13513 (throw 'exit t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13514 nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13515
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13516 (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
13517 "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
13518 (interactive "sOrg-files matching: \np")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13519 (let* ((files (org-agenda-files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13520 (tnames (mapcar 'file-truename files))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13521 (extra org-agenda-text-search-extra-files)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13522 f)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13523 (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
13524 (setq extra (cdr extra))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13525 (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
13526 (while (setq f (pop extra))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13527 (unless (member (file-truename f) tnames)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13528 (add-to-list 'files f 'append)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13529 (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
13530 (multi-occur
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13531 (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
13532 regexp)))
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 (if (boundp 'occur-mode-find-occurrence-hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13535 ;; Emacs 23
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13536 (add-hook 'occur-mode-find-occurrence-hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13537 (lambda ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13538 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13539 (org-reveal))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13540 ;; Emacs 22
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13541 (defadvice occur-mode-goto-occurrence
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13542 (after org-occur-reveal activate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13543 (and (org-mode-p) (org-reveal)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13544 (defadvice occur-mode-goto-occurrence-other-window
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13545 (after org-occur-reveal activate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13546 (and (org-mode-p) (org-reveal)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13547 (defadvice occur-mode-display-occurrence
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13548 (after org-occur-reveal activate)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13549 (when (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13550 (let ((pos (occur-mode-find-occurrence)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13551 (with-current-buffer (marker-buffer pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13552 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13553 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13554 (org-reveal)))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13555
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13556 (defun org-uniquify (list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13557 "Remove duplicate elements from LIST."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13558 (let (res)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13559 (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
13560 res))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13561
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13562 (defun org-delete-all (elts list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13563 "Remove all elements in ELTS from LIST."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13564 (while elts
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13565 (setq list (delete (pop elts) list)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13566 list)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13567
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13568 (defun org-back-over-empty-lines ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13569 "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
13570 Returns the number of empty lines passed."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13571 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13572 (skip-chars-backward " \t\n\r")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13573 (beginning-of-line 2)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13574 (goto-char (min (point) pos))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13575 (count-lines (point) pos)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13576
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13577 (defun org-skip-whitespace ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13578 (skip-chars-forward " \t\n\r"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13579
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13580 (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
13581 "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
13582 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
13583 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
13584 return nil."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13585 (and (match-beginning group)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13586 (>= point (match-beginning group))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13587 (<= point (match-end group))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13588 (if context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13589 (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
13590 t)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13591
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13592 (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
13593 "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
13594 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
13595 (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
13596 special-display-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13597 (apply 'switch-to-buffer-other-window args)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13598
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13599 (defun org-combine-plists (&rest plists)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13600 "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
13601 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
13602 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
13603 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
13604 (let ((rtn (copy-sequence (pop plists)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13605 p v ls)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13606 (while plists
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13607 (setq ls (pop plists))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13608 (while ls
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13609 (setq p (pop ls) v (pop ls))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13610 (setq rtn (plist-put rtn p v))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13611 rtn))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13612
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13613 (defun org-move-line-down (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13614 "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
13615 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13616 (let ((col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13617 beg end pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13618 (beginning-of-line 1) (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13619 (beginning-of-line 2) (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13620 (beginning-of-line (+ 1 arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13621 (setq pos (move-marker (make-marker) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13622 (insert (delete-and-extract-region beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13623 (goto-char pos)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13624 (org-move-to-column col)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13625
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13626 (defun org-move-line-up (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13627 "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
13628 (interactive "p")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13629 (let ((col (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13630 beg end pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13631 (beginning-of-line 1) (setq beg (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13632 (beginning-of-line 2) (setq end (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13633 (beginning-of-line (- arg))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13634 (setq pos (move-marker (make-marker) (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13635 (insert (delete-and-extract-region beg end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13636 (goto-char pos)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13637 (org-move-to-column col)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13638
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13639 (defun org-replace-escapes (string table)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13640 "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
13641 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
13642 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
13643 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
13644 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
13645 (let ((case-fold-search nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13646 e re rpl)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13647 (while (setq e (pop table))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13648 (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
13649 (while (string-match re string)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13650 (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
13651 (cdr e)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13652 (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
13653 string))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13654
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-sublist (list start end)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13657 "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
13658 Counting starts at 1."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13659 (let (rtn (c start))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13660 (setq list (nthcdr (1- start) list))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13661 (while (and list (<= c end))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13662 (push (pop list) rtn)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13663 (setq c (1+ c)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13664 (nreverse rtn)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13665
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13666 (defun org-find-base-buffer-visiting (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13667 "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
13668 not an indirect buffer."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13669 (let ((buf (find-buffer-visiting file)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13670 (if buf
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13671 (or (buffer-base-buffer buf) buf)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13672 nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13673
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13674 (defun org-image-file-name-regexp ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13675 "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
13676 (if (fboundp 'image-file-name-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13677 (image-file-name-regexp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13678 (let ((image-file-name-extensions
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13679 '("png" "jpeg" "jpg" "gif" "tiff" "tif"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13680 "xbm" "xpm" "pbm" "pgm" "ppm")))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13681 (concat "\\."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13682 (regexp-opt (nconc (mapcar 'upcase
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13683 image-file-name-extensions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13684 image-file-name-extensions)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13685 t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13686 "\\'"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13687
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13688 (defun org-file-image-p (file)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13689 "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
13690 (save-match-data
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13691 (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
13692
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13693 (defun org-get-cursor-date ()
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13694 "Return the date at cursor in as a time.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13695 This works in the calendar and in the agenda, anywhere else it just
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13696 returns the current time."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13697 (let (date day defd)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13698 (cond
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13699 ((eq major-mode 'calendar-mode)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13700 (setq date (calendar-cursor-to-date)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13701 defd (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13702 ((eq major-mode 'org-agenda-mode)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13703 (setq day (get-text-property (point) 'day))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13704 (if day
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13705 (setq date (calendar-gregorian-from-absolute day)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13706 defd (encode-time 0 0 0 (nth 1 date) (nth 0 date)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13707 (nth 2 date))))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13708 (or defd (current-time))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13709
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13710 (defvar org-agenda-action-marker (make-marker)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13711 "Marker pointing to the entry for the next agenda action.")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13712
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13713 (defun org-mark-entry-for-agenda-action ()
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13714 "Mark the current entry as target of an agenda action.
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13715 Agenda actions are actions executed from the agenda with the key `k',
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13716 which make use of the date at the cursor."
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13717 (interactive)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13718 (move-marker org-agenda-action-marker
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13719 (save-excursion (org-back-to-heading t) (point))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13720 (current-buffer))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13721 (message
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13722 "Entry marked for action; press `k' at desired date in agenda or calendar"))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13723
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13724 ;;; Paragraph filling stuff.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13725 ;; 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
13726
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13727 (defun org-indent-line-function ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13728 "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
13729 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13730 (let* ((pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13731 (itemp (org-at-item-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13732 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
13733 ;; Find the previous relevant line
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13734 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13735 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13736 ((looking-at "#") (setq column 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13737 ((looking-at "\\*+ ") (setq column 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13738 (t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13739 (beginning-of-line 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13740 (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
13741 (beginning-of-line 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13742 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13743 ((looking-at "\\*+[ \t]+")
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13744 (if (not org-adapt-indentation)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13745 (setq column 0)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13746 (goto-char (match-end 0))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13747 (setq column (current-column))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13748 ((org-in-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13749 (org-beginning-of-item)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13750 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \\)?")
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13751 (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
13752 bcol (progn (goto-char bpos) (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13753 tcol (progn (goto-char tpos) (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13754 bullet (match-string 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13755 bullet-type (if (string-match "[0-9]" bullet) "n" bullet))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13756 (if (> tcol (+ bcol org-description-max-indent))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13757 (setq tcol (+ bcol 5)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13758 (if (not itemp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13759 (setq column tcol)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13760 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13761 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13762 (if (looking-at "\\S-")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13763 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13764 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13765 (setq bullet (match-string 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13766 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
13767 (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
13768 (setq column (org-get-indentation)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13769 (t (setq column (org-get-indentation))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13770 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13771 (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
13772 (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
13773 (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
13774 (setq column (current-column))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13775 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13776 (if (looking-at
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13777 "\\([ \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
13778 (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
13779 (match-string 2) (match-string 3)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13780 t nil))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13781 (org-move-to-column column)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13782
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13783 (defun org-set-autofill-regexps ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13784 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13785 ;; 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
13786 ;; 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
13787 ;; fill the headline as well.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13788 (org-set-local 'comment-start-skip "^#+[ \t]*")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13789 (org-set-local 'paragraph-separate "\f\\|\\*+ \\|[ ]*$\\|[ \t]*[:|]")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13790 ;; The paragraph starter includes hand-formatted lists.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13791 (org-set-local 'paragraph-start
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13792 "\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
13793 ;; 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
13794 ;; 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
13795 (org-set-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13796 'auto-fill-inhibit-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13797 (concat "\\*+ \\|#\\+"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13798 "\\|[ \t]*" org-keyword-time-regexp
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13799 (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
13800 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13801 "\\|[ \t]*["
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13802 (if org-enable-table-editor "|" "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13803 (if org-enable-fixed-width-editor ":" "")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13804 "]"))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13805 ;; 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
13806 ;; 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
13807 ;; through to `fill-paragraph' when appropriate.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13808 (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
13809 ; 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
13810 ;; `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
13811 (org-set-local 'adaptive-fill-regexp "\000")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13812 (org-set-local 'adaptive-fill-function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13813 'org-adaptive-fill-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13814 (org-set-local
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13815 'align-mode-rules-list
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13816 '((org-in-buffer-settings
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13817 (regexp . "^#\\+[A-Z_]+:\\(\\s-*\\)\\S-+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13818 (modes . '(org-mode))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13819
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13820 (defun org-fill-paragraph (&optional justify)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13821 "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
13822 (let ((table-p (org-at-table-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13823 (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
13824 (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
13825 (save-excursion (goto-char (point-at-bol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13826 (looking-at outline-regexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13827 t) ; skip headlines
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13828 (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
13829 (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
13830 (t nil)))) ; call paragraph-fill
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13831
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13832 ;; 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
13833 ;; "[ \t]*\\([-|#;>*]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13834
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13835 (defun org-adaptive-fill-function ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13836 "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
13837 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
13838 work correctly."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13839 (cond ((looking-at "#[ \t]+")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13840 (match-string 0))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13841 ((looking-at "[ \t]*\\([-*+] .*? :: \\)")
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13842 (save-excursion
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13843 (if (> (match-end 1) (+ (match-beginning 1)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13844 org-description-max-indent))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13845 (goto-char (+ (match-beginning 1) 5))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13846 (goto-char (match-end 0)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13847 (make-string (current-column) ?\ )))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13848 ((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)] \\)?")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13849 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13850 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13851 (make-string (current-column) ?\ )))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13852 (t nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13853
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13854 ;;; Other stuff.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13855
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13856 (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
13857 "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
13858 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
13859 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
13860 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
13861 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
13862 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
13863 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
13864 (interactive "P")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13865 (let* ((cc 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13866 (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
13867 (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
13868 (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
13869 (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
13870 (case-fold-search nil)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13871 (re "[ \t]*\\(:\\)")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13872 off)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13873 (if regionp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13874 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13875 (goto-char beg)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13876 (setq cc (current-column))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13877 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13878 (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
13879 (while (> nlines 0)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13880 (setq nlines (1- nlines))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13881 (beginning-of-line 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13882 (cond
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13883 (arg
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13884 (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
13885 (insert ":\n")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13886 (forward-line -1))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13887 ((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
13888 (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
13889 ((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
13890 (forward-line 1)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13891 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13892 (org-back-to-heading)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13893 (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
13894 "\\( *\\<" org-quote-string "\\>[ \t]*\\)"))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13895 (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
13896 (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
13897 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13898 (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
13899 (insert org-quote-string " "))))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
13900
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13901 ;;;; Functions extending outline functionality
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13902
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13903 (defun org-beginning-of-line (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13904 "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
13905 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
13906 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
13907 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
13908 beyond the end of the headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13909 (interactive "P")
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13910 (let ((pos (point)) refpos)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13911 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13912 (if (bobp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13913 nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13914 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13915 (if (org-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13916 (while (and (not (bobp)) (org-invisible-p))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13917 (backward-char 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13918 (beginning-of-line 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13919 (forward-char 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13920 (when org-special-ctrl-a/e
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13921 (cond
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13922 ((and (looking-at org-complex-heading-regexp)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13923 (= (char-after (match-end 1)) ?\ ))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13924 (setq refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1)))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13925 (point-at-eol)))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13926 (goto-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13927 (if (eq org-special-ctrl-a/e t)
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13928 (cond ((> pos refpos) refpos)
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13929 ((= pos (point)) refpos)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13930 (t (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13931 (cond ((> pos (point)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13932 ((not (eq last-command this-command)) (point))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13933 (t refpos)))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13934 ((org-at-item-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13935 (goto-char
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13936 (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
13937 (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
13938 ((= pos (point)) (match-end 4))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13939 (t (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13940 (cond ((> pos (point)) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13941 ((not (eq last-command this-command)) (point))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13942 (t (match-end 4))))))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13943 (org-no-warnings
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13944 (and (featurep 'xemacs) (setq zmacs-region-stays t)))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13945
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13946 (defun org-end-of-line (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13947 "Go to the end of the line.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13948 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
13949 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
13950 beyond the end of the headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13951 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13952 (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
13953 (not (org-on-heading-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13954 (end-of-line arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13955 (let ((pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13956 (beginning-of-line 1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13957 (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
13958 (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
13959 (if (or (< pos (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13960 (= pos (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13961 (goto-char (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13962 (goto-char (match-end 0)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13963 (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
13964 (goto-char (match-end 0))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13965 (goto-char (match-beginning 1))))
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13966 (end-of-line arg))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13967 (org-no-warnings
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13968 (and (featurep 'xemacs) (setq zmacs-region-stays t))))
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
13969
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13970
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13971 (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
13972 (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
13973
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13974 (defun org-kill-line (&optional arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13975 "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
13976 (interactive "P")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13977 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13978 ((or (not org-special-ctrl-k)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13979 (bolp)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13980 (not (org-on-heading-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13981 (call-interactively 'kill-line))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13982 ((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
13983 (kill-region (point) (match-beginning 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13984 (org-set-tags nil t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13985 (t (kill-region (point) (point-at-eol)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13986
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13987 (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
13988
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13989 (defun org-yank (&optional arg)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13990 "Yank. If the kill is a subtree, treat it specially.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13991 This command will look at the current kill and check if is a single
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13992 subtree, or a series of subtrees[1]. If it passes the test, and if the
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13993 cursor is at the beginning of a line or after the stars of a currently
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13994 empty headline, then the yank is handeled specially. How exactly depends
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13995 on the value of the following variables, both set by default.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13996
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13997 org-yank-folded-subtrees
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13998 When set, the subree(s) will be folded after insertion, but only
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
13999 if doing so would now swallow text after the yanked text.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14000
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14001 org-yank-adjusted-subtrees
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14002 When set, the subtree will be promoted or demoted in order to
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14003 fit into the local outline tree structure, which means that the level
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14004 will be adjusted so that it becomes the smaller one of the two
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14005 *visible* surrounding headings.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14006
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14007 Any prefix to this command will cause `yank' to be called directly with
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14008 no special treatment. In particular, a simple `C-u' prefix will just
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14009 plainly yank the text as it is.
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14010
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14011 \[1] Basically, the test checks if the first non-white line is a heading
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14012 and if there are no other headings with fewer stars."
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14013 (interactive "P")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14014 (if arg
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14015 (call-interactively 'yank)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14016 (let ((subtreep ; is kill a subtree, and the yank position appropriate?
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14017 (and (org-kill-is-subtree-p)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14018 (or (bolp)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14019 (and (looking-at "[ \t]*$")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14020 (string-match
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14021 "\\`\\*+\\'"
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14022 (buffer-substring (point-at-bol) (point)))))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14023 swallowp)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14024 (cond
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14025 ((and subtreep org-yank-folded-subtrees)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14026 (let ((beg (point))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14027 end)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14028 (if (and subtreep org-yank-adjusted-subtrees)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14029 (org-paste-subtree nil nil 'for-yank)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14030 (call-interactively 'yank))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14031 (setq end (point))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14032 (goto-char beg)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14033 (when (and (bolp) subtreep
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14034 (not (setq swallowp
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14035 (org-yank-folding-would-swallow-text beg end))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14036 (or (looking-at outline-regexp)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14037 (re-search-forward (concat "^" outline-regexp) end t))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14038 (while (and (< (point) end) (looking-at outline-regexp))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14039 (hide-subtree)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14040 (org-cycle-show-empty-lines 'folded)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14041 (condition-case nil
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14042 (outline-forward-same-level 1)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14043 (error (goto-char end)))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14044 (when swallowp
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14045 (message
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14046 "Yanked text not folded because that would swallow text"))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14047 (goto-char end)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14048 (skip-chars-forward " \t\n\r")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14049 (beginning-of-line 1)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14050 ((and subtreep org-yank-adjusted-subtrees)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14051 (org-paste-subtree nil nil 'for-yank))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14052 (t
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14053 (call-interactively 'yank))))))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14054
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14055 (defun org-yank-folding-would-swallow-text (beg end)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14056 "Would hide-subtree at BEG swallow any text after END?"
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14057 (let (level)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14058 (save-excursion
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14059 (goto-char beg)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14060 (when (or (looking-at outline-regexp)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14061 (re-search-forward (concat "^" outline-regexp) end t))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14062 (setq level (org-outline-level)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14063 (goto-char end)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14064 (skip-chars-forward " \t\r\n\v\f")
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14065 (if (or (eobp)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14066 (and (bolp) (looking-at org-outline-regexp)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14067 (<= (org-outline-level) level)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14068 nil ; Nothing would be swallowed
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14069 t)))) ; something would swallow
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14070
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14071 (define-key org-mode-map "\C-y" 'org-yank)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14072
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14073 (defun org-invisible-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14074 "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
14075 ;; 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
14076 (if (fboundp 'outline-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14077 (outline-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14078 (get-char-property (point) 'invisible)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14079
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14080 (defun org-invisible-p2 ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14081 "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
14082 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14083 (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
14084 ;; 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
14085 (if (fboundp 'outline-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14086 (outline-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14087 (get-char-property (point) 'invisible))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14088
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14089 (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
14090 (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
14091 (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
14092 (defun org-at-heading-or-item-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14093 (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
14094
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14095 (defun org-on-target-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14096 (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
14097 (org-in-regexp org-target-regexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14098
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14099 (defun org-up-heading-all (arg)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14100 "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
14101 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
14102 With argument, move up ARG levels."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14103 (if (fboundp 'outline-up-heading-all)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14104 (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
14105 (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
14106
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14107 (defun org-up-heading-safe ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14108 "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
14109 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
14110 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
14111 (let ((pos (point)) start-level level
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14112 (re (concat "^" outline-regexp)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14113 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14114 (outline-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14115 (setq start-level (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14116 (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
14117 (while (re-search-backward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14118 (setq level (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14119 (if (< level start-level) (throw 'exit level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14120 nil)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14121
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14122 (defun org-first-sibling-p ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14123 "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
14124 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14125 (let ((re (concat "^" outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14126 level l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14127 (unless (org-at-heading-p t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14128 (error "Not at a heading"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14129 (setq level (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14130 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14131 (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
14132 t
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14133 (setq l (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14134 (< l level)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14135
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14136 (defun org-goto-sibling (&optional previous)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14137 "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
14138 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
14139 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
14140 move point."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14141 (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
14142 (pos (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14143 (re (concat "^" outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14144 level l)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14145 (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
14146 (setq level (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14147 (catch 'exit
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14148 (or previous (forward-char 1))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14149 (while (funcall fun re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14150 (setq l (funcall outline-level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14151 (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
14152 (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
14153 (goto-char pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14154 nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14155
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14156 (defun org-show-siblings ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14157 "Show all siblings of the current headline."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14158 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14159 (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
14160 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14161 (while (org-goto-sibling 'previous)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14162 (org-flag-heading nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14163
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14164 (defun org-show-hidden-entry ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14165 "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
14166 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14167 (org-show-entry)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14168
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14169 (defun org-flag-heading (flag &optional entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14170 "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
14171 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
14172 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14173 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14174 ;; 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
14175 (if entry
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14176 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14177 (org-show-entry)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14178 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14179 (and (outline-next-heading)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14180 (org-flag-heading nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14181 (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
14182 (save-excursion (outline-end-of-heading) (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14183 flag))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14184
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14185 (defun org-forward-same-level (arg)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14186 "Move forward to the ARG'th subheading at same level as this one.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14187 Stop at the first and last subheadings of a superior heading.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14188 This is like outline-forward-same-level, but invisible headings are ok."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14189 (interactive "p")
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14190 (outline-back-to-heading t)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14191 (while (> arg 0)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14192 (let ((point-to-move-to (save-excursion
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14193 (org-get-next-sibling))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14194 (if point-to-move-to
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14195 (progn
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14196 (goto-char point-to-move-to)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14197 (setq arg (1- arg)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14198 (progn
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14199 (setq arg 0)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14200 (error "No following same-level heading"))))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14201
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14202 (defun org-get-next-sibling ()
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14203 "Move to next heading of the same level, and return point.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14204 If there is no such heading, return nil.
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14205 This is like outline-next-sibling, but invisible headings are ok."
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14206 (let ((level (funcall outline-level)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14207 (outline-next-heading)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14208 (while (and (not (eobp)) (> (funcall outline-level) level))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14209 (outline-next-heading))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14210 (if (or (eobp) (< (funcall outline-level) level))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14211 nil
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14212 (point))))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14213
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14214 (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
14215 ;; 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
14216 ;; `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
14217 ;; 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
14218 ;; 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
14219 (org-back-to-heading invisible-OK)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14220 (let ((first t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14221 (level (funcall outline-level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14222 (while (and (not (eobp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14223 (or first (> (funcall outline-level) level)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14224 (setq first nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14225 (outline-next-heading))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14226 (unless to-heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14227 (if (memq (preceding-char) '(?\n ?\^M))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14228 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14229 ;; Go to end of line before heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14230 (forward-char -1)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14231 (if (memq (preceding-char) '(?\n ?\^M))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14232 ;; leave blank line before heading
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14233 (forward-char -1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14234 (point))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14235
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14236 (defun org-show-subtree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14237 "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
14238 (outline-flag-region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14239 (point)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14240 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14241 (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
14242 nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14243
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14244 (defun org-show-entry ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14245 "Show the body directly following this heading.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14246 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
14247 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14248 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14249 (condition-case nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14250 (progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14251 (org-back-to-heading t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14252 (outline-flag-region
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14253 (max (point-min) (1- (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14254 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14255 (re-search-forward
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14256 (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14257 (or (match-beginning 1) (point-max)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14258 nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14259 (error nil))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14260
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14261 (defun org-make-options-regexp (kwds)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14262 "Make a regular expression for keyword lines."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14263 (concat
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14264 "^"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14265 "#?[ \t]*\\+\\("
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14266 (mapconcat 'regexp-quote kwds "\\|")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14267 "\\):[ \t]*"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14268 "\\(.+\\)"))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14269
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14270 ;; Make isearch reveal the necessary context
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14271 (defun org-isearch-end ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14272 "Reveal context after isearch exits."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14273 (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
14274 (if (featurep 'xemacs)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14275 ;; 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
14276 ;; we directly show the context.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14277 (org-show-context 'isearch)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14278 ;; 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
14279 ;; 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
14280 ;; (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
14281 (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
14282 isearch-mode-end-hook-quit)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14283 ;; Only when the isearch was not quitted.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14284 (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
14285 'append 'local)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14286
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14287 (defun org-isearch-post-command ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14288 "Remove self from hook, and show context."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14289 (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
14290 (org-show-context 'isearch))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14291
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14292
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14293 ;;;; Integration with and fixes for other packages
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14294
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14295 ;;; Imenu support
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14296
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14297 (defvar org-imenu-markers nil
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14298 "All markers currently used by Imenu.")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14299 (make-variable-buffer-local 'org-imenu-markers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14300
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14301 (defun org-imenu-new-marker (&optional pos)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14302 "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
14303 (let ((m (make-marker)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14304 (move-marker m (or pos (point)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14305 (push m org-imenu-markers)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14306 m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14307
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14308 (defun org-imenu-get-tree ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14309 "Produce the index for Imenu."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14310 (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
14311 (setq org-imenu-markers nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14312 (let* ((n org-imenu-depth)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14313 (re (concat "^" outline-regexp))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14314 (subs (make-vector (1+ n) nil))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14315 (last-level 0)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14316 m tree level head)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14317 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14318 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14319 (widen)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14320 (goto-char (point-max))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14321 (while (re-search-backward re nil t)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14322 (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
14323 (when (<= level n)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14324 (looking-at org-complex-heading-regexp)
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14325 (setq head (org-link-display-format
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14326 (org-match-string-no-properties 4))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14327 m (org-imenu-new-marker))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14328 (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
14329 (if (>= level last-level)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14330 (push (cons head m) (aref subs level))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14331 (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
14332 (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
14333 (setq last-level level)))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14334 (aref subs 1)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14335
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14336 (eval-after-load "imenu"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14337 '(progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14338 (add-hook 'imenu-after-jump-hook
96975
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
14339 (lambda ()
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
14340 (if (eq major-mode 'org-mode)
60149c696033 2008-07-24 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 96826
diff changeset
14341 (org-show-context 'org-goto))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14342
98644
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14343 (defun org-link-display-format (link)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14344 "Replace a link with either the description, or the link target
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14345 if no description is present"
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14346 (save-match-data
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14347 (if (string-match org-bracket-link-analytic-regexp link)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14348 (replace-match (or (match-string 5 link)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14349 (concat (match-string 1 link)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14350 (match-string 3 link)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14351 nil nil link)
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14352 link)))
e1cc41b9282d 2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 97390
diff changeset
14353
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14354 ;; Speedbar support
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14355
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
14356 (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
14357 "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
14358 (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
14359 '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
14360 (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
14361 '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
14362 (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
14363
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14364 (defun org-speedbar-set-agenda-restriction ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14365 "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
14366 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
14367 (interactive)
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
14368 (require 'org-agenda)
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14369 (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
14370 (cond
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14371 ((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
14372 'org-imenu t))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14373 (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
14374 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14375 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14376 (set-buffer (marker-buffer m))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14377 (goto-char m)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14378 (org-agenda-set-restriction-lock 'subtree))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14379 ((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
14380 'speedbar-function 'speedbar-find-file))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14381 (setq tp (previous-single-property-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14382 (1+ p) 'speedbar-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14383 np (next-single-property-change
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14384 tp 'speedbar-function)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14385 dir (speedbar-line-directory)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14386 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
14387 (or np (point-max))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14388 (save-excursion
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14389 (save-restriction
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14390 (set-buffer (find-file-noselect
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14391 (let ((default-directory dir))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14392 (expand-file-name txt))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14393 (unless (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14394 (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
14395 (org-agenda-set-restriction-lock 'file))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14396 (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
14397 (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
14398 (point-at-bol) (point-at-eol))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14399 (setq current-prefix-arg nil)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14400 (org-agenda-maybe-redo)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14401
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14402 (eval-after-load "speedbar"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14403 '(progn
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14404 (speedbar-add-supported-extension ".org")
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14405 (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
14406 (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
14407 (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
14408 (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
14409 (add-hook 'speedbar-visiting-tag-hook
99690
1c73544f73bf * org.el ("speedbar"): Only show context if the file really is an
Carsten Dominik <dominik@science.uva.nl>
parents: 99656
diff changeset
14410 (lambda () (and (org-mode-p) (org-show-context 'org-goto))))))
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14411
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14412
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 93810
diff changeset
14413 ;;; 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
14414
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14415 ;; 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
14416 (defun org-mode-flyspell-verify ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14417 "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
14418 (not (get-text-property (point) 'keymap)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14419
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14420 ;; 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
14421 (eval-after-load "bookmark"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14422 '(if (boundp 'bookmark-after-jump-hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14423 ;; We can use the hook
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14424 (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
14425 ;; Hook not available, use advice
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14426 (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
14427 "Make the position visible."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14428 (org-bookmark-jump-unhide))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14429
99501
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14430 ;; Make sure saveplace show the location if it was hidden
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14431 (eval-after-load "saveplace"
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14432 '(defadvice save-place-find-file-hook (after org-make-visible activate)
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14433 "Make the position visible."
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14434 (org-bookmark-jump-unhide)))
e3acb52d33e1 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99386
diff changeset
14435
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14436 (defun org-bookmark-jump-unhide ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14437 "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
14438 (and (org-mode-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14439 (or (org-invisible-p)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14440 (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
14441 (org-invisible-p)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14442 (org-show-context 'bookmark-jump)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14443
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14444 ;; Make session.el ignore our circular variable
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14445 (eval-after-load "session"
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14446 '(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
14447
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14448 ;;;; Experimental code
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14449
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14450 (defun org-closed-in-range ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14451 "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
14452 Still experimental, may disappear in the future."
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14453 (interactive)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14454 ;; Get the time interval from the user.
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14455 (let* ((time1 (time-to-seconds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14456 (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
14457 (time2 (time-to-seconds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14458 (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
14459 ;; callback function
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14460 (callback (lambda ()
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14461 (let ((time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14462 (time-to-seconds
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14463 (apply 'encode-time
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14464 (org-parse-time-string
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14465 (match-string 1))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14466 ;; check if time in interval
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14467 (and (>= time time1) (<= time time2))))))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14468 ;; 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
14469 (org-occur "CLOSED: +\\[\\(.*?\\)\\]" nil callback)))
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14470
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14471
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14472 ;;;; Finish up
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14473
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14474 (provide 'org)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14475
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14476 (run-hooks 'org-load-hook)
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14477
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14478 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94876
diff changeset
14479
93141
dda2c82177dc Move org files to their own directory
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14480 ;;; org.el ends here