Mercurial > emacs
annotate lisp/org/org-macs.el @ 104711:adeed914a5fb
* vc.el (vc-print-log-internal): Move RCS/CVS specific code ...
* vc-rcs.el (vc-rcs-print-log-cleanup): ... here. New function.
(vc-rcs-print-log): Use it.
* vc-cvs.el (vc-cvs-print-log): Use vc-rcs-print-log-cleanup.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sat, 29 Aug 2009 18:56:12 +0000 |
parents | ac1a55cc2c38 |
children | 86b7fe7d1d8f |
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 |
101515
64ef70f990a9
2009-01-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
101458
diff
changeset
|
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 |
64ef70f990a9
2009-01-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
101458
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
5 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
6 ;; 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
|
7 ;; Keywords: outlines, hypermedia, calendar, wp |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
8 ;; Homepage: http://orgmode.org |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
9 ;; Version: 6.29c |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
10 ;; |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
11 ;; 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
|
12 ;; |
94676
ba3167bc4143
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94441
diff
changeset
|
13 ;; 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
|
14 ;; 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
|
15 ;; 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
|
16 ;; (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
|
17 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
18 ;; 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
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
23 ;; 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
|
24 ;; 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
|
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
26 ;; |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
27 ;;; Commentary: |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
28 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
29 ;; 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
|
30 ;; 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
|
31 ;; 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
|
32 ;; generally useful stuff. |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
33 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
34 ;;; Code: |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
35 |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
36 (eval-and-compile |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
37 (unless (fboundp 'declare-function) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
38 (defmacro declare-function (fn file &optional arglist fileonly)))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
39 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
40 (declare-function org-add-props "org-compat" (string plist &rest props)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
41 |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
42 (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
|
43 "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
|
44 `(and (boundp (quote ,var)) ,var)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
45 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
46 (defmacro org-unmodified (&rest body) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
47 "Execute body without changing `buffer-modified-p'. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
48 Also, do not record undo information." |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
49 `(set-buffer-modified-p |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
50 (prog1 (buffer-modified-p) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
51 (let ((buffer-undo-list t) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
52 before-change-functions after-change-functions) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
53 ,@body)))) |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
54 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
55 (defmacro org-re (s) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
56 "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
|
57 (if (featurep 'xemacs) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
58 (let ((ss s)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
59 (save-match-data |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
60 (while (string-match "\\[:alnum:\\]" ss) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
61 (setq ss (replace-match "a-zA-Z0-9" t t ss))) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
62 (while (string-match "\\[:word:\\]" ss) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
63 (setq ss (replace-match "a-zA-Z0-9" t t ss))) |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
64 (while (string-match "\\[:alpha:\\]" ss) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
65 (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
|
66 ss)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
67 s)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
68 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
69 (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
|
70 `(let ((_line (org-current-line)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
71 (_col (current-column))) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
72 (unwind-protect |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
73 (progn ,@body) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
74 (goto-line _line) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
75 (org-move-to-column _col)))) |
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-without-partial-completion (&rest body) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
78 `(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
|
79 partial-completion-mode))) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
80 (unwind-protect |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
81 (progn |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
82 (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
|
83 ,@body) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
84 (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
|
85 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
86 (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
|
87 "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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 (if (< emacs-major-version 22) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
95 `(append '(intangible t) ,props) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
96 props)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
97 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
98 (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
|
99 "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
|
100 `(save-excursion |
96044
c1ef445563bb
2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
94768
diff
changeset
|
101 (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
|
102 (save-excursion |
96044
c1ef445563bb
2008-06-17 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
94768
diff
changeset
|
103 (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
|
104 ,@body))) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
105 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
106 (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
|
107 (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
|
108 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
109 (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
|
110 "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
|
111 `(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
|
112 ,@body)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
113 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
114 (defmacro org-if-unprotected-1 (&rest body) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
115 "Execute BODY if there is no `org-protected' text property at point-1." |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
116 `(unless (get-text-property (1- (point)) 'org-protected) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
117 ,@body)) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
118 |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
119 (defmacro org-if-unprotected-at (pos &rest body) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
120 "Execute BODY if there is no `org-protected' text property at point-1." |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
121 `(unless (get-text-property ,pos 'org-protected) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
122 ,@body)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
123 |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
124 (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
|
125 "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
|
126 `(let ((_cline (org-current-line)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
127 (_cmd this-command) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
128 (_buf1 (current-buffer)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
129 (_buf2 ,_buffer) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
130 (_undo1 buffer-undo-list) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
131 (_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
|
132 _c1 _c2) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
133 ,@_body |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
134 (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
|
135 (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
|
136 _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
|
137 _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
|
138 _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
|
139 (when (or _c1 _c2) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
140 ;; 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
|
141 (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
|
142 (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
|
143 ;; remember which buffer to undo |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
144 (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
|
145 org-agenda-undo-list))))) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
146 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
147 (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
|
148 "Inhibit read-only for BODY." |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
149 `(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
|
150 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
151 (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
|
152 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
|
153 "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
|
154 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
155 (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
|
156 (if (featurep 'xemacs) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
157 (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
|
158 (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
|
159 s) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
160 (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
|
161 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
162 (defsubst org-no-properties (s) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
163 (if (fboundp 'set-text-properties) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
164 (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
|
165 (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
|
166 s) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
167 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
168 (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
|
169 (cond ((eq key t) t) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
170 ((eq option t) t) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
171 ((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
|
172 (t (cdr (assq 'default option))))) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
173 |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
174 (defsubst org-check-external-command (cmd &optional use no-error) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
175 "Check if external progam CMD for USE exists, error if not. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
176 When the program does exist, return it's path. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
177 When it does not exist and NO-ERROR is set, return nil. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
178 Otherwise, throw an error. The optional argument USE can describe what this |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
179 program is needed for, so that the error message can be more informative." |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
180 (or (executable-find cmd) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
181 (if no-error |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
182 nil |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
183 (error "Can't find `%s'%s" cmd |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
184 (if use (format " (%s)" use) ""))))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
185 |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
186 (defsubst org-inhibit-invisibility () |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
187 "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
|
188 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
|
189 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
|
190 (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
|
191 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
192 (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
|
193 "Make VAR local in current buffer and set it to VALUE." |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
194 (set (make-local-variable var) value)) |
94414
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 (defsubst org-mode-p () |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
197 "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
|
198 (eq major-mode 'org-mode)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
199 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
200 (defsubst org-last (list) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
201 "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
|
202 (car (last list))) |
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-let (list &rest body) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
205 (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
|
206 (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
|
207 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
208 (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
|
209 (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
|
210 (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
|
211 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
212 (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
|
213 "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
|
214 (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
|
215 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
216 (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
|
217 (save-excursion |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
218 (and pos (goto-char pos)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
219 ;; 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
|
220 (+ (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
|
221 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
222 (defsubst org-current-line-string (&optional to-here) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
223 (buffer-substring (point-at-bol) (if to-here (point) (point-at-eol)))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
224 |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
225 (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
|
226 (and (match-beginning n) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
227 (<= (match-beginning n) pos) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
228 (>= (match-end n) pos))) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
229 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
230 (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
|
231 "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
|
232 (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
|
233 file)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
234 f) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
235 (while (setq f (pop functions)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
236 (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
|
237 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
238 (defun org-match-line (re) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
239 "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
|
240 (save-excursion |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
241 (goto-char (point-at-bol)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
242 (looking-at re))) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
243 |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
244 (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
|
245 "Delete PROPERTY from PLIST. |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
246 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
|
247 (let (p) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
248 (while plist |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
249 (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
|
250 (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
|
251 (setq plist (cddr plist))) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
252 p)) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
253 |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
254 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
255 (defun org-replace-match-keep-properties (newtext &optional fixedcase |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
256 literal string) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
257 "Like `replace-match', but add the text properties found original text." |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
258 (setq newtext (org-add-props newtext (text-properties-at |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
259 (match-beginning 0) string))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
260 (replace-match newtext fixedcase literal string)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
261 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
262 (defmacro org-with-limited-levels (&rest body) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
263 "Execute BODY with limited number of outline levels." |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
264 `(let* ((outline-regexp (org-get-limited-outline-regexp))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
265 ,@body)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
266 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
267 (defvar org-odd-levels-only) ; defined in org.el |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
268 (defvar org-inlinetask-min-level) ; defined in org-inlinetask.el |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
269 (defun org-get-limited-outline-regexp () |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
270 "Return outline-regexp with limited number of levels. |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
271 The number of levels is controlled by " |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
272 (if (or (not (org-mode-p)) (not (featurep 'org-inlinetask))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
273 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
274 outline-regexp |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
275 (let* ((limit-level (1- org-inlinetask-min-level)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
276 (nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
277 (format "\\*\\{1,%d\\} " nstars)))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
278 |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
279 (provide 'org-macs) |
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
280 |
94441 | 281 ;; 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
|
282 |
94414
d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
283 ;;; org-macs.el ends here |