annotate lisp/org/org-macs.el @ 101183:96e4db45c8a5

(menu-bar-help-extra-packages): Use goto-address-mode instead of goto-address.
author Juri Linkov <juri@jurta.org>
date Wed, 14 Jan 2009 23:11:12 +0000
parents a9dc0e7c3f2b
children 36abe982e7cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; org-macs.el --- Top-level definitions for Org-mode
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100605
diff changeset
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6 ;; Keywords: outlines, hypermedia, calendar, wp
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7 ;; Homepage: http://orgmode.org
100605
0d3c634e0bd9 2008-12-20 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100458
diff changeset
8 ;; Version: 6.16
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9 ;;
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
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: 94441
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
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: 94441
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: 94441
diff changeset
15 ;; (at your option) any later version.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
16
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
20 ;; GNU General Public License for more details.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
21
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
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: 94441
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25 ;;
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
26 ;;; Commentary:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
27
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
28 ;; This file contains macro definitions, defsubst definitions, other
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29 ;; stuff needed for compilation and top-level forms in Org-mode, as well
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 ;; lots of small functions that are not org-mode specific but simply
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 ;; generally useful stuff.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 ;;; Code:
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 (defmacro org-bound-and-true-p (var)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 "Return the value of symbol VAR if it is bound, else nil."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 `(and (boundp (quote ,var)) ,var))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 (defmacro org-unmodified (&rest body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40 "Execute body without changing `buffer-modified-p'."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 `(set-buffer-modified-p
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42 (prog1 (buffer-modified-p) ,@body)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 (defmacro org-re (s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 "Replace posix classes in regular expression."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 (if (featurep 'xemacs)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 (let ((ss s))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 (save-match-data
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 (while (string-match "\\[:alnum:\\]" ss)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 (setq ss (replace-match "a-zA-Z0-9" t t ss)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 (while (string-match "\\[:alpha:\\]" ss)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 (setq ss (replace-match "a-zA-Z" t t ss)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53 ss))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54 s))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56 (defmacro org-preserve-lc (&rest body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 `(let ((_line (org-current-line))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58 (_col (current-column)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 (unwind-protect
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 (progn ,@body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 (goto-line _line)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 (org-move-to-column _col))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64 (defmacro org-without-partial-completion (&rest body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 `(let ((pc-mode (and (boundp 'partial-completion-mode)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 partial-completion-mode)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
67 (unwind-protect
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68 (progn
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
69 (if pc-mode (partial-completion-mode -1))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70 ,@body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 (if pc-mode (partial-completion-mode 1)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
73 (eval-and-compile
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74 (unless (fboundp 'declare-function)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
75 (defmacro declare-function (fn file &optional arglist fileonly))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77 (defmacro org-maybe-intangible (props)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
78 "Add '(intangible t) to PROPS if Emacs version is earlier than Emacs 22.
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79 In emacs 21, invisible text is not avoided by the command loop, so the
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80 intangible property is needed to make sure point skips this text.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81 In Emacs 22, this is not necessary. The intangible text property has
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 led to problems with flyspell. These problems are fixed in flyspell.el,
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 but we still avoid setting the property in Emacs 22 and later.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
84 We use a macro so that the test can happen at compilation time."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85 (if (< emacs-major-version 22)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
86 `(append '(intangible t) ,props)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87 props))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
88
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
89 (defmacro org-with-point-at (pom &rest body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
90 "Move to buffer and point of point-or-marker POM for the duration of BODY."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
91 `(save-excursion
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94768
diff changeset
92 (if (markerp ,pom) (set-buffer (marker-buffer ,pom)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93 (save-excursion
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94768
diff changeset
94 (goto-char (or ,pom (point)))
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95 ,@body)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
97 (defmacro org-no-warnings (&rest body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 (cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100 (defmacro org-if-unprotected (&rest body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101 "Execute BODY if there is no `org-protected' text property at point."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102 `(unless (get-text-property (point) 'org-protected)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103 ,@body))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105 (defmacro org-with-remote-undo (_buffer &rest _body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 "Execute BODY while recording undo information in two buffers."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107 `(let ((_cline (org-current-line))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108 (_cmd this-command)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109 (_buf1 (current-buffer))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 (_buf2 ,_buffer)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 (_undo1 buffer-undo-list)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 (_undo2 (with-current-buffer ,_buffer buffer-undo-list))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 _c1 _c2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 ,@_body
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115 (when org-agenda-allow-remote-undo
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 (setq _c1 (org-verify-change-for-undo
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 _undo1 (with-current-buffer _buf1 buffer-undo-list))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 _c2 (org-verify-change-for-undo
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 _undo2 (with-current-buffer _buf2 buffer-undo-list)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 (when (or _c1 _c2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 ;; make sure there are undo boundaries
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 (and _c1 (with-current-buffer _buf1 (undo-boundary)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123 (and _c2 (with-current-buffer _buf2 (undo-boundary)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 ;; remember which buffer to undo
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
125 (push (list _cmd _cline _buf1 _c1 _buf2 _c2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 org-agenda-undo-list)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
127
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128 (defmacro org-no-read-only (&rest body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 "Inhibit read-only for BODY."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
130 `(let ((inhibit-read-only t)) ,@body))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 (defconst org-rm-props '(invisible t face t keymap t intangible t mouse-face t
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 rear-nonsticky t mouse-map t fontified t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 "Properties to remove when a string without properties is wanted.")
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 (defsubst org-match-string-no-properties (num &optional string)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 (if (featurep 'xemacs)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 (let ((s (match-string num string)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 (and s (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:
diff changeset
140 s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141 (match-string-no-properties num string)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 (defsubst org-no-properties (s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 (if (fboundp 'set-text-properties)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145 (set-text-properties 0 (length s) nil s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146 (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:
diff changeset
147 s)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
148
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149 (defsubst org-get-alist-option (option key)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 (cond ((eq key t) t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151 ((eq option t) t)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 ((assoc key option) (cdr (assoc key option)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 (t (cdr (assq 'default option)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 (defsubst org-inhibit-invisibility ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 "Modified `buffer-invisibility-spec' for Emacs 21.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 Some ops with invisible text do not work correctly on Emacs 21. For these
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 we turn off invisibility temporarily. Use this in a `let' form."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 (if (< emacs-major-version 22) nil buffer-invisibility-spec))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 (defsubst org-set-local (var value)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162 "Make VAR local in current buffer and set it to VALUE."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 (set (make-variable-buffer-local var) value))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165 (defsubst org-mode-p ()
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 "Check if the current buffer is in Org-mode."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167 (eq major-mode 'org-mode))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169 (defsubst org-last (list)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170 "Return the last element of LIST."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171 (car (last list)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173 (defun org-let (list &rest body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174 (eval (cons 'let (cons list body))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
175 (put 'org-let 'lisp-indent-function 1)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
176
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 (defun org-let2 (list1 list2 &rest body)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178 (eval (cons 'let (cons list1 (list (cons 'let (cons list2 body)))))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 (put 'org-let2 'lisp-indent-function 2)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 (defsubst org-call-with-arg (command arg)
94768
c30d898f0375 (org-call-with-arg, org-autoload): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
182 "Call COMMAND interactively, but pretend prefix arg was ARG."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183 (let ((current-prefix-arg arg)) (call-interactively command)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 (defsubst org-current-line (&optional pos)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 (and pos (goto-char pos))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 ;; works also in narrowed buffer, because we start at 1, not point-min
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189 (+ (if (bolp) 1 0) (count-lines 1 (point)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 (defsubst org-pos-in-match-range (pos n)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 (and (match-beginning n)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 (<= (match-beginning n) pos)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194 (>= (match-end n) pos)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196 (defun org-autoload (file functions)
94768
c30d898f0375 (org-call-with-arg, org-autoload): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 94676
diff changeset
197 "Establish autoload for all FUNCTIONS in FILE, if not bound already."
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198 (let ((d (format "Documentation will be available after `%s.el' is loaded."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 file))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 f)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 (while (setq f (pop functions))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 (or (fboundp f) (autoload f file d t)))))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 (defun org-match-line (re)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 "Looking-at at the beginning of the current line."
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206 (save-excursion
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 (goto-char (point-at-bol))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208 (looking-at re)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210 (defun org-plist-delete (plist property)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 "Delete PROPERTY from PLIST.
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 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:
diff changeset
213 (let (p)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 (while plist
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215 (if (not (eq property (car plist)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 (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:
diff changeset
217 (setq plist (cddr plist)))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 p))
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220 (provide 'org-macs)
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221
94441
da5141d2e8fc Add arch tagline
Miles Bader <miles@gnu.org>
parents: 94414
diff changeset
222 ;; arch-tag: 7e6a73ce-aac9-4fc0-9b30-ce6f89dc6668
96044
c1ef445563bb 2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 94768
diff changeset
223
94414
d86cb59eea9f 2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 ;;; org-macs.el ends here