aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes/org.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/textmodes/org.el')
-rw-r--r--lisp/textmodes/org.el935
1 files changed, 611 insertions, 324 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index bbc59768aaf..635bb6b5a98 100644
--- a/lisp/textmodes/org.el
+++ b/lisp/textmodes/org.el
@@ -1,11 +1,11 @@
1;; org.el --- Outline-based notes management and organizer 1;;; org.el --- Outline-based notes management and organizer
2;; Carstens outline-mode for keeping track of everything. 2;; Carstens outline-mode for keeping track of everything.
3;; Copyright (c) 2004, 2005 Free Software Foundation 3;; Copyright (c) 2004, 2005 Free Software Foundation
4;; 4;;
5;; Author: Carsten Dominik <dominik at science dot uva dot nl> 5;; Author: Carsten Dominik <dominik at science dot uva dot nl>
6;; Keywords: outlines, hypermedia, calendar 6;; Keywords: outlines, hypermedia, calendar
7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ 7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
8;; Version: 3.10 8;; Version: 3.11
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -80,6 +80,17 @@
80;; 80;;
81;; Changes: 81;; Changes:
82;; ------- 82;; -------
83;; Version 3.11
84;; - Links inserted with C-c C-l are now by default enclosed in angle
85;; brackets. See the new variable `org-link-format'.
86;; - ">" terminates a link, this is a way to have several links in a line.
87;; - Archiving of finished tasks.
88;; - C-<up>/<down> bindings removed, to allow access to paragraph commands.
89;; - Compatibility with CUA-mode (see variable `org-CUA-compatible').
90;; - Compatibility problems with viper-mode fixed.
91;; - Improved html export of tables.
92;; - Various clean-up changes.
93;;
83;; Version 3.10 94;; Version 3.10
84;; - Using `define-derived-mode' to derive `org-mode' from `outline-mode'. 95;; - Using `define-derived-mode' to derive `org-mode' from `outline-mode'.
85;; 96;;
@@ -154,12 +165,10 @@
154(require 'outline) 165(require 'outline)
155(require 'time-date) 166(require 'time-date)
156(require 'easymenu) 167(require 'easymenu)
157(or (fboundp 'run-mode-hooks)
158 (defalias 'run-mode-hooks 'run-hooks))
159 168
160;;; Customization variables 169;;; Customization variables
161 170
162(defvar org-version "3.10" 171(defvar org-version "3.11"
163 "The version number of the file org.el.") 172 "The version number of the file org.el.")
164(defun org-version () 173(defun org-version ()
165 (interactive) 174 (interactive)
@@ -185,6 +194,44 @@
185 :tag "Org Startup" 194 :tag "Org Startup"
186 :group 'org) 195 :group 'org)
187 196
197(defcustom org-CUA-compatible nil
198 "Non-nil means use alternative key bindings for S-<cursor movement>.
199Org-mode used S-<cursor movement> for changing timestamps and priorities.
200S-<cursor movement> is also used for example by `CUA-mode' to select text.
201If you want to use Org-mode together with `CUA-mode', Org-mode needs to use
202alternative bindings. Setting this variable to t will replace the following
203keys both in Org-mode and in the Org-agenda buffer.
204
205S-RET -> C-S-RET
206S-up -> M-p
207S-down -> M-n
208S-left -> M--
209S-right -> M-+
210
211If you do not like the alternative keys, take a look at the variable
212`org-disputed-keys'.
213
214This option is only relevant at load-time of Org-mode. Changing it requires
215a restart of Emacs to become effective."
216 :group 'org-startup
217 :type 'boolean)
218
219(defvar org-disputed-keys
220 '((S-up [(shift up)] [(meta ?p)])
221 (S-down [(shift down)] [(meta ?n)])
222 (S-left [(shift left)] [(meta ?-)])
223 (S-right [(shift right)] [(meta ?+)])
224 (S-return [(shift return)] [(control shift return)]))
225 "Keys for which Org-mode and other modes compete.
226This is an alist, cars are symbols for lookup, 1st element is the default key,
227second element will be used when `org-CUA-compatible' is t.")
228
229(defun org-key (key)
230 "Select a key according to `org-CUA-compatible'."
231 (nth (if org-CUA-compatible 2 1)
232 (or (assq key org-disputed-keys)
233 (error "Invalid Key %s in `org-key'" key))))
234
188(defcustom org-startup-folded t 235(defcustom org-startup-folded t
189 "Non-nil means, entering Org-mode will switch to OVERVIEW. 236 "Non-nil means, entering Org-mode will switch to OVERVIEW.
190This can also be configured on a per-file basis by adding one of 237This can also be configured on a per-file basis by adding one of
@@ -388,16 +435,17 @@ is used instead.")
388 "Precompute regular expressions for current buffer." 435 "Precompute regular expressions for current buffer."
389 (when (eq major-mode 'org-mode) 436 (when (eq major-mode 'org-mode)
390 (let ((re (org-make-options-regexp 437 (let ((re (org-make-options-regexp
391 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP"))) 438 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO"
439 "STARTUP" "ARCHIVE")))
392 (splitre "[ \t]+") 440 (splitre "[ \t]+")
393 kwds int key value cat) 441 kwds int key value cat arch)
394 (save-excursion 442 (save-excursion
395 (save-restriction 443 (save-restriction
396 (widen) 444 (widen)
397 (goto-char (point-min)) 445 (goto-char (point-min))
398 (while (re-search-forward re nil t) 446 (while (re-search-forward re nil t)
399 (setq key (match-string 1) value (match-string 2)) 447 (setq key (match-string 1) value (match-string 2))
400 (cond 448 (cond
401 ((equal key "CATEGORY") 449 ((equal key "CATEGORY")
402 (if (string-match "[ \t]+$" value) 450 (if (string-match "[ \t]+$" value)
403 (setq value (replace-match "" t t value))) 451 (setq value (replace-match "" t t value)))
@@ -421,17 +469,23 @@ is used instead.")
421 l var val) 469 l var val)
422 (while (setq l (assoc (pop opts) set)) 470 (while (setq l (assoc (pop opts) set))
423 (setq var (nth 1 l) val (nth 2 l)) 471 (setq var (nth 1 l) val (nth 2 l))
424 (set (make-local-variable var) val))))) 472 (set (make-local-variable var) val))))
473 ((equal key "ARCHIVE")
474 (string-match " *$" value)
475 (setq arch (replace-match "" t t value))
476 (remove-text-properties 0 (length arch)
477 '(face t fontified t) arch)))
425 ))) 478 )))
426 (and cat (set (make-local-variable 'org-category) cat)) 479 (and cat (set (make-local-variable 'org-category) cat))
427 (and kwds (set (make-local-variable 'org-todo-keywords) kwds)) 480 (and kwds (set (make-local-variable 'org-todo-keywords) kwds))
481 (and arch (set (make-local-variable 'org-archive-location) arch))
428 (and int (set (make-local-variable 'org-todo-interpretation) int))) 482 (and int (set (make-local-variable 'org-todo-interpretation) int)))
429 ;; Compute the regular expressions and other local variables 483 ;; Compute the regular expressions and other local variables
430 (setq org-todo-kwd-priority-p (equal org-todo-interpretation 'priority) 484 (setq org-todo-kwd-priority-p (equal org-todo-interpretation 'priority)
431 org-todo-kwd-max-priority (1- (length org-todo-keywords)) 485 org-todo-kwd-max-priority (1- (length org-todo-keywords))
432 org-ds-keyword-length (+ 2 (max (length org-deadline-string) 486 org-ds-keyword-length (+ 2 (max (length org-deadline-string)
433 (length org-scheduled-string))) 487 (length org-scheduled-string)))
434 org-done-string 488 org-done-string
435 (nth (1- (length org-todo-keywords)) org-todo-keywords) 489 (nth (1- (length org-todo-keywords)) org-todo-keywords)
436 org-todo-regexp 490 org-todo-regexp
437 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords 491 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords
@@ -465,6 +519,11 @@ is used instead.")
465 :tag "Org Time" 519 :tag "Org Time"
466 :group 'org) 520 :group 'org)
467 521
522(defconst org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")
523 "Formats for `format-time-string' which are used for time stamps.
524It is not recommended to change this constant.")
525
526
468(defcustom org-deadline-warning-days 30 527(defcustom org-deadline-warning-days 30
469 "No. of days before expiration during which a deadline becomes active. 528 "No. of days before expiration during which a deadline becomes active.
470This variable governs the display in the org file." 529This variable governs the display in the org file."
@@ -506,7 +565,7 @@ When nil, cursor will remain in the current window."
506 565
507(defcustom org-select-agenda-window t 566(defcustom org-select-agenda-window t
508 "Non-nil means, after creating an agenda, move cursor into Agenda window. 567 "Non-nil means, after creating an agenda, move cursor into Agenda window.
509When nil, cursor will remain in the current window." 568When nil, cursor will remain in the current window."
510 :group 'org-agenda 569 :group 'org-agenda
511 :type 'boolean) 570 :type 'boolean)
512 571
@@ -542,7 +601,7 @@ When nil, always start on the current day."
542When nil, date-less entries will only be shown if `org-agenda' is called 601When nil, date-less entries will only be shown if `org-agenda' is called
543with a prefix argument. 602with a prefix argument.
544When non-nil, the TODO entries will be listed at the top of the agenda, before 603When non-nil, the TODO entries will be listed at the top of the agenda, before
545the entries for specific days." 604the entries for specific days."
546 :group 'org-agenda 605 :group 'org-agenda
547 :type 'boolean) 606 :type 'boolean)
548 607
@@ -587,7 +646,7 @@ priority.
587Leaving out `category-keep' would mean that items will be sorted across 646Leaving out `category-keep' would mean that items will be sorted across
588categories by priority." 647categories by priority."
589 :group 'org-agenda 648 :group 'org-agenda
590 :type '(repeat 649 :type '(repeat
591 (choice 650 (choice
592 (const time-up) 651 (const time-up)
593 (const time-down) 652 (const time-down)
@@ -663,14 +722,26 @@ the variable `org-agenda-time-grid'."
663 :group 'org-agenda 722 :group 'org-agenda
664 :type 'boolean) 723 :type 'boolean)
665 724
666(defcustom org-agenda-time-grid 725(defcustom org-agenda-time-grid
667 '((daily today require-timed) 726 '((daily today require-timed)
668 "----------------" 727 "----------------"
669 (800 1000 1200 1400 1600 1800 2000)) 728 (800 1000 1200 1400 1600 1800 2000))
670 729
671 "FIXME: document" 730 "The settings for time grid for agenda display.
731This is a list of three items. The first item is again a list. It contains
732symbols specifying conditions when the grid should be displayed:
733
734 daily if the agenda shows a single day
735 weekly if the agenda shows an entire week
736 today show grid on current date, independent of daily/weekly display
737 require-timed show grid only if at least on item has a time specification
738
739The second item is a string which will be places behing the grid time.
740
741The third item is a list of integers, indicating the times that should have
742a grid line."
672 :group 'org-agenda 743 :group 'org-agenda
673 :type 744 :type
674 '(list 745 '(list
675 (set :greedy t :tag "Grid Display Options" 746 (set :greedy t :tag "Grid Display Options"
676 (const :tag "Show grid in single day agenda display" daily) 747 (const :tag "Show grid in single day agenda display" daily)
@@ -752,10 +823,6 @@ t Everywhere except in headlines"
752 (const :tag "Everywhere except in headlines" t) 823 (const :tag "Everywhere except in headlines" t)
753 )) 824 ))
754 825
755(defconst org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")
756 "Formats for `format-time-string' which are used for time stamps.
757It is not recommended to change this constant.")
758
759(defcustom org-show-following-heading t 826(defcustom org-show-following-heading t
760 "Non-nil means, show heading following match in `org-occur'. 827 "Non-nil means, show heading following match in `org-occur'.
761When doing an `org-occur' it is useful to show the headline which 828When doing an `org-occur' it is useful to show the headline which
@@ -766,12 +833,73 @@ unnecessary clutter."
766 :group 'org-structure 833 :group 'org-structure
767 :type 'boolean) 834 :type 'boolean)
768 835
836(defcustom org-archive-location "%s_archive::"
837 "The location where subtrees should be archived.
838This string consists of two parts, separated by a double-colon.
839
840The first part is a file name - when omitted, archiving happens in the same
841file. %s will be replaced by the current file name (without directory part).
842Archiving to a different file is useful to keep archived entries from
843contributing to the Org-mode Agenda.
844
845The part after the double colon is a headline. The archived entries will be
846filed under that headline. When omitted, the subtrees are simply filed away
847at the end of the file, as top-level entries.
848
849Here are a few examples:
850\"%s_archive::\"
851 If the current file is Projects.org, archive in file
852 Projects.org_archive, as top-level trees. This is the default.
853
854\"::* Archived Tasks\"
855 Archive in the current file, under the top-level headline
856 \"* Archived Tasks\".
857
858\"~/org/archive.org::\"
859 Archive in file ~/org/archive.org (absolute path), as top-level trees.
860
861\"basement::** Finished Tasks\"
862 Archive in file ./basement (relative path), as level 3 trees
863 below the level 2 heading \"** Finished Tasks\".
864
865You may set this option on a per-file basis by adding to the buffer a
866line like
867
868#+ARCHIVE: basement::** Finished Tasks"
869 :group 'org-structure
870 :type 'string)
871
872(defcustom org-archive-mark-done t
873 "Non-nil means, mark archived entries as DONE."
874 :group 'org-structure
875 :type 'boolean)
876
877(defcustom org-archive-stamp-time t
878 "Non-nil means, add a time stamp to archived entries.
879The time stamp will be added directly after the TODO state keyword in the
880first line, so it is probably best to use this in combinations with
881`org-archive-mark-done'."
882 :group 'org-structure
883 :type 'boolean)
769 884
770(defgroup org-link nil 885(defgroup org-link nil
771 "Options concerning links in Org-mode." 886 "Options concerning links in Org-mode."
772 :tag "Org Link" 887 :tag "Org Link"
773 :group 'org) 888 :group 'org)
774 889
890(defcustom org-link-format "<%s>"
891 "Default format for linkes in the buffer.
892This is a format string for printf, %s will be replaced by the link text.
893If you want to make sure that your link is always properly terminated,
894include angle brackets into this format, like \"<%s>\". Some people also
895recommend an additional URL: prefix, so the format would be \"<URL:%s>\"."
896 :group 'org-link
897 :type '(choice
898 (const :tag "\"%s\" (e.g. http://www.there.com)" "%s")
899 (const :tag "\"<%s>\" (e.g. <http://www.there.com>)" "<%s>")
900 (const :tag "\"<URL:%s>\" (e.g. <URL:http://www.there.com>)" "<URL:%s>")
901 (string :tag "Other" :value "<%s>")))
902
775(defcustom org-allow-space-in-links t 903(defcustom org-allow-space-in-links t
776 "Non-nil means, file names in links may contain space characters. 904 "Non-nil means, file names in links may contain space characters.
777When nil, it becomes possible to put several links into a line. 905When nil, it becomes possible to put several links into a line.
@@ -1310,7 +1438,7 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1310 :tag "Org Faces" 1438 :tag "Org Faces"
1311 :group 'org) 1439 :group 'org)
1312 1440
1313(defface org-level-1-face ;; font-lock-function-name-face 1441(defface org-level-1 ;; font-lock-function-name-face
1314 '((((type tty) (class color)) (:foreground "blue" :weight bold)) 1442 '((((type tty) (class color)) (:foreground "blue" :weight bold))
1315 (((class color) (background light)) (:foreground "Blue")) 1443 (((class color) (background light)) (:foreground "Blue"))
1316 (((class color) (background dark)) (:foreground "LightSkyBlue")) 1444 (((class color) (background dark)) (:foreground "LightSkyBlue"))
@@ -1318,7 +1446,7 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1318 "Face used for level 1 headlines." 1446 "Face used for level 1 headlines."
1319 :group 'org-faces) 1447 :group 'org-faces)
1320 1448
1321(defface org-level-2-face ;; font-lock-variable-name-face 1449(defface org-level-2 ;; font-lock-variable-name-face
1322 '((((type tty) (class color)) (:foreground "yellow" :weight light)) 1450 '((((type tty) (class color)) (:foreground "yellow" :weight light))
1323 (((class color) (background light)) (:foreground "DarkGoldenrod")) 1451 (((class color) (background light)) (:foreground "DarkGoldenrod"))
1324 (((class color) (background dark)) (:foreground "LightGoldenrod")) 1452 (((class color) (background dark)) (:foreground "LightGoldenrod"))
@@ -1326,7 +1454,7 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1326 "Face used for level 2 headlines." 1454 "Face used for level 2 headlines."
1327 :group 'org-faces) 1455 :group 'org-faces)
1328 1456
1329(defface org-level-3-face ;; font-lock-keyword-face 1457(defface org-level-3 ;; font-lock-keyword-face
1330 '((((type tty) (class color)) (:foreground "cyan" :weight bold)) 1458 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
1331 (((class color) (background light)) (:foreground "Purple")) 1459 (((class color) (background light)) (:foreground "Purple"))
1332 (((class color) (background dark)) (:foreground "Cyan")) 1460 (((class color) (background dark)) (:foreground "Cyan"))
@@ -1334,7 +1462,7 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1334 "Face used for level 3 headlines." 1462 "Face used for level 3 headlines."
1335 :group 'org-faces) 1463 :group 'org-faces)
1336 1464
1337(defface org-level-4-face ;; font-lock-comment-face 1465(defface org-level-4 ;; font-lock-comment-face
1338 '((((type tty pc) (class color) (background light)) (:foreground "red")) 1466 '((((type tty pc) (class color) (background light)) (:foreground "red"))
1339 (((type tty pc) (class color) (background dark)) (:foreground "red1")) 1467 (((type tty pc) (class color) (background dark)) (:foreground "red1"))
1340 (((class color) (background light)) (:foreground "Firebrick")) 1468 (((class color) (background light)) (:foreground "Firebrick"))
@@ -1343,7 +1471,7 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1343 "Face used for level 4 headlines." 1471 "Face used for level 4 headlines."
1344 :group 'org-faces) 1472 :group 'org-faces)
1345 1473
1346(defface org-level-5-face ;; font-lock-type-face 1474(defface org-level-5 ;; font-lock-type-face
1347 '((((type tty) (class color)) (:foreground "green")) 1475 '((((type tty) (class color)) (:foreground "green"))
1348 (((class color) (background light)) (:foreground "ForestGreen")) 1476 (((class color) (background light)) (:foreground "ForestGreen"))
1349 (((class color) (background dark)) (:foreground "PaleGreen")) 1477 (((class color) (background dark)) (:foreground "PaleGreen"))
@@ -1351,7 +1479,7 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1351 "Face used for level 5 headlines." 1479 "Face used for level 5 headlines."
1352 :group 'org-faces) 1480 :group 'org-faces)
1353 1481
1354(defface org-level-6-face ;; font-lock-constant-face 1482(defface org-level-6 ;; font-lock-constant-face
1355 '((((type tty) (class color)) (:foreground "magenta")) 1483 '((((type tty) (class color)) (:foreground "magenta"))
1356 (((class color) (background light)) (:foreground "CadetBlue")) 1484 (((class color) (background light)) (:foreground "CadetBlue"))
1357 (((class color) (background dark)) (:foreground "Aquamarine")) 1485 (((class color) (background dark)) (:foreground "Aquamarine"))
@@ -1359,7 +1487,7 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1359 "Face used for level 6 headlines." 1487 "Face used for level 6 headlines."
1360 :group 'org-faces) 1488 :group 'org-faces)
1361 1489
1362(defface org-level-7-face ;; font-lock-builtin-face 1490(defface org-level-7 ;; font-lock-builtin-face
1363 '((((type tty) (class color)) (:foreground "blue" :weight light)) 1491 '((((type tty) (class color)) (:foreground "blue" :weight light))
1364 (((class color) (background light)) (:foreground "Orchid")) 1492 (((class color) (background light)) (:foreground "Orchid"))
1365 (((class color) (background dark)) (:foreground "LightSteelBlue")) 1493 (((class color) (background dark)) (:foreground "LightSteelBlue"))
@@ -1367,7 +1495,7 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1367 "Face used for level 7 headlines." 1495 "Face used for level 7 headlines."
1368 :group 'org-faces) 1496 :group 'org-faces)
1369 1497
1370(defface org-level-8-face ;; font-lock-string-face 1498(defface org-level-8 ;; font-lock-string-face
1371 '((((type tty) (class color)) (:foreground "green")) 1499 '((((type tty) (class color)) (:foreground "green"))
1372 (((class color) (background light)) (:foreground "RosyBrown")) 1500 (((class color) (background light)) (:foreground "RosyBrown"))
1373 (((class color) (background dark)) (:foreground "LightSalmon")) 1501 (((class color) (background dark)) (:foreground "LightSalmon"))
@@ -1375,7 +1503,7 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1375 "Face used for level 8 headlines." 1503 "Face used for level 8 headlines."
1376 :group 'org-faces) 1504 :group 'org-faces)
1377 1505
1378(defface org-warning-face ;; font-lock-warning-face 1506(defface org-warning ;; font-lock-warning-face
1379 '((((type tty) (class color)) (:foreground "red")) 1507 '((((type tty) (class color)) (:foreground "red"))
1380 (((class color) (background light)) (:foreground "Red" :bold t)) 1508 (((class color) (background light)) (:foreground "Red" :bold t))
1381 (((class color) (background dark)) (:foreground "Red1" :bold t)) 1509 (((class color) (background dark)) (:foreground "Red1" :bold t))
@@ -1388,11 +1516,11 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1388 "Non-nil means, change the face of a headline if it is marked DONE. 1516 "Non-nil means, change the face of a headline if it is marked DONE.
1389Normally, only the TODO/DONE keyword indicates the state of a headline. 1517Normally, only the TODO/DONE keyword indicates the state of a headline.
1390When this is non-nil, the headline after the keyword is set to the 1518When this is non-nil, the headline after the keyword is set to the
1391`org-headline-done-face' as an additional indication." 1519`org-headline-done' as an additional indication."
1392 :group 'org-faces 1520 :group 'org-faces
1393 :type 'boolean) 1521 :type 'boolean)
1394 1522
1395(defface org-headline-done-face ;; font-lock-string-face 1523(defface org-headline-done ;; font-lock-string-face
1396 '((((type tty) (class color)) (:foreground "green")) 1524 '((((type tty) (class color)) (:foreground "green"))
1397 (((class color) (background light)) (:foreground "RosyBrown")) 1525 (((class color) (background light)) (:foreground "RosyBrown"))
1398 (((class color) (background dark)) (:foreground "LightSalmon")) 1526 (((class color) (background dark)) (:foreground "LightSalmon"))
@@ -1403,7 +1531,7 @@ When this is non-nil, the headline after the keyword is set to the
1403 1531
1404;; Inheritance does not yet work for xemacs. So we just copy... 1532;; Inheritance does not yet work for xemacs. So we just copy...
1405 1533
1406(defface org-deadline-announce-face 1534(defface org-deadline-announce
1407 '((((type tty) (class color)) (:foreground "blue" :weight bold)) 1535 '((((type tty) (class color)) (:foreground "blue" :weight bold))
1408 (((class color) (background light)) (:foreground "Blue")) 1536 (((class color) (background light)) (:foreground "Blue"))
1409 (((class color) (background dark)) (:foreground "LightSkyBlue")) 1537 (((class color) (background dark)) (:foreground "LightSkyBlue"))
@@ -1411,7 +1539,7 @@ When this is non-nil, the headline after the keyword is set to the
1411 "Face for upcoming deadlines." 1539 "Face for upcoming deadlines."
1412 :group 'org-faces) 1540 :group 'org-faces)
1413 1541
1414(defface org-scheduled-today-face 1542(defface org-scheduled-today
1415 '((((type tty) (class color)) (:foreground "green")) 1543 '((((type tty) (class color)) (:foreground "green"))
1416 (((class color) (background light)) (:foreground "DarkGreen")) 1544 (((class color) (background light)) (:foreground "DarkGreen"))
1417 (((class color) (background dark)) (:foreground "PaleGreen")) 1545 (((class color) (background dark)) (:foreground "PaleGreen"))
@@ -1419,7 +1547,7 @@ When this is non-nil, the headline after the keyword is set to the
1419 "Face for items scheduled for a certain day." 1547 "Face for items scheduled for a certain day."
1420 :group 'org-faces) 1548 :group 'org-faces)
1421 1549
1422(defface org-scheduled-previously-face 1550(defface org-scheduled-previously
1423 '((((type tty pc) (class color) (background light)) (:foreground "red")) 1551 '((((type tty pc) (class color) (background light)) (:foreground "red"))
1424 (((type tty pc) (class color) (background dark)) (:foreground "red1")) 1552 (((type tty pc) (class color) (background dark)) (:foreground "red1"))
1425 (((class color) (background light)) (:foreground "Firebrick")) 1553 (((class color) (background light)) (:foreground "Firebrick"))
@@ -1428,7 +1556,7 @@ When this is non-nil, the headline after the keyword is set to the
1428 "Face for items scheduled previously, and not yet done." 1556 "Face for items scheduled previously, and not yet done."
1429 :group 'org-faces) 1557 :group 'org-faces)
1430 1558
1431(defface org-link-face 1559(defface org-link
1432 '((((type tty) (class color)) (:foreground "cyan" :weight bold)) 1560 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
1433 (((class color) (background light)) (:foreground "Purple")) 1561 (((class color) (background light)) (:foreground "Purple"))
1434 (((class color) (background dark)) (:foreground "Cyan")) 1562 (((class color) (background dark)) (:foreground "Cyan"))
@@ -1436,7 +1564,7 @@ When this is non-nil, the headline after the keyword is set to the
1436 "Face for links." 1564 "Face for links."
1437 :group 'org-faces) 1565 :group 'org-faces)
1438 1566
1439(defface org-done-face ;; font-lock-type-face 1567(defface org-done ;; font-lock-type-face
1440 '((((type tty) (class color)) (:foreground "green")) 1568 '((((type tty) (class color)) (:foreground "green"))
1441 (((class color) (background light)) (:foreground "ForestGreen" :bold t)) 1569 (((class color) (background light)) (:foreground "ForestGreen" :bold t))
1442 (((class color) (background dark)) (:foreground "PaleGreen" :bold t)) 1570 (((class color) (background dark)) (:foreground "PaleGreen" :bold t))
@@ -1444,7 +1572,7 @@ When this is non-nil, the headline after the keyword is set to the
1444 "Face used for DONE." 1572 "Face used for DONE."
1445 :group 'org-faces) 1573 :group 'org-faces)
1446 1574
1447(defface org-table-face ;; font-lock-function-name-face 1575(defface org-table ;; font-lock-function-name-face
1448 '((((type tty) (class color)) (:foreground "blue" :weight bold)) 1576 '((((type tty) (class color)) (:foreground "blue" :weight bold))
1449 (((class color) (background light)) (:foreground "Blue")) 1577 (((class color) (background light)) (:foreground "Blue"))
1450 (((class color) (background dark)) (:foreground "LightSkyBlue")) 1578 (((class color) (background dark)) (:foreground "LightSkyBlue"))
@@ -1452,7 +1580,7 @@ When this is non-nil, the headline after the keyword is set to the
1452 "Face used for tables." 1580 "Face used for tables."
1453 :group 'org-faces) 1581 :group 'org-faces)
1454 1582
1455(defface org-time-grid-face ;; font-lock-variable-name-face 1583(defface org-time-grid ;; font-lock-variable-name-face
1456 '((((type tty) (class color)) (:foreground "yellow" :weight light)) 1584 '((((type tty) (class color)) (:foreground "yellow" :weight light))
1457 (((class color) (background light)) (:foreground "DarkGoldenrod")) 1585 (((class color) (background light)) (:foreground "DarkGoldenrod"))
1458 (((class color) (background dark)) (:foreground "LightGoldenrod")) 1586 (((class color) (background dark)) (:foreground "LightGoldenrod"))
@@ -1462,14 +1590,14 @@ When this is non-nil, the headline after the keyword is set to the
1462 1590
1463(defvar org-level-faces 1591(defvar org-level-faces
1464 '( 1592 '(
1465 org-level-1-face 1593 org-level-1
1466 org-level-2-face 1594 org-level-2
1467 org-level-3-face 1595 org-level-3
1468 org-level-4-face 1596 org-level-4
1469 org-level-5-face 1597 org-level-5
1470 org-level-6-face 1598 org-level-6
1471 org-level-7-face 1599 org-level-7
1472 org-level-8-face 1600 org-level-8
1473 )) 1601 ))
1474(defvar org-n-levels (length org-level-faces)) 1602(defvar org-n-levels (length org-level-faces))
1475 1603
@@ -1535,7 +1663,7 @@ sets it back to nil.")
1535 1663
1536;;;###autoload 1664;;;###autoload
1537(define-derived-mode org-mode outline-mode "Org" 1665(define-derived-mode org-mode outline-mode "Org"
1538 "Outline-based notes management and organizer, alias 1666 "Outline-based notes management and organizer, alias
1539\"Carstens outline-mode for keeping track of everything.\" 1667\"Carstens outline-mode for keeping track of everything.\"
1540 1668
1541Org-mode develops organizational tasks around a NOTES file which 1669Org-mode develops organizational tasks around a NOTES file which
@@ -1564,6 +1692,9 @@ The following commands are available:
1564 (make-local-hook 'before-change-functions) ;; needed for XEmacs 1692 (make-local-hook 'before-change-functions) ;; needed for XEmacs
1565 (add-hook 'before-change-functions 'org-before-change-function nil 1693 (add-hook 'before-change-functions 'org-before-change-function nil
1566 'local) 1694 'local)
1695 ;; Paragraph regular expressions
1696 (set (make-local-variable 'paragraph-separate) "\f\\|[ ]*$")
1697 (set (make-local-variable 'paragraph-start) "\f\\|[ ]*$\\|\\([*\f]+\\)")
1567 ;; Inhibit auto-fill for headers, tables and fixed-width lines. 1698 ;; Inhibit auto-fill for headers, tables and fixed-width lines.
1568 (set (make-local-variable 'auto-fill-inhibit-regexp) 1699 (set (make-local-variable 'auto-fill-inhibit-regexp)
1569 (concat "\\*" 1700 (concat "\\*"
@@ -1573,6 +1704,7 @@ The following commands are available:
1573 (if org-enable-table-editor "|" "") 1704 (if org-enable-table-editor "|" "")
1574 (if org-enable-fixed-width-editor ":" "") 1705 (if org-enable-fixed-width-editor ":" "")
1575 "]")))) 1706 "]"))))
1707 (set (make-local-variable 'fill-paragraph-function) 'org-fill-paragraph)
1576 (if (and org-insert-mode-line-in-empty-file 1708 (if (and org-insert-mode-line-in-empty-file
1577 (interactive-p) 1709 (interactive-p)
1578 (= (point-min) (point-max))) 1710 (= (point-min) (point-max)))
@@ -1587,25 +1719,38 @@ The following commands are available:
1587 (let ((this-command 'org-cycle) (last-command 'org-cycle)) 1719 (let ((this-command 'org-cycle) (last-command 'org-cycle))
1588 (org-cycle '(4)) (org-cycle '(4)))))))) 1720 (org-cycle '(4)) (org-cycle '(4))))))))
1589 1721
1722(defun org-fill-paragraph (&optional justify)
1723 "Re-align a table, pass through to fill-paragraph if no table."
1724 (save-excursion
1725 (beginning-of-line 1)
1726 (looking-at "\\s-*\\(|\\|\\+-+\\)")))
1727
1590;;; Font-Lock stuff 1728;;; Font-Lock stuff
1591 1729
1592(defvar org-mouse-map (make-sparse-keymap)) 1730(defvar org-mouse-map (make-sparse-keymap))
1593(define-key org-mouse-map 1731(define-key org-mouse-map
1594 (if org-xemacs-p [button2] [mouse-2]) 'org-open-at-mouse) 1732 (if org-xemacs-p [button2] [mouse-2]) 'org-open-at-mouse)
1595(define-key org-mouse-map 1733(define-key org-mouse-map
1596 (if org-xemacs-p [button3] [mouse-3]) 'org-find-file-at-mouse) 1734 (if org-xemacs-p [button3] [mouse-3]) 'org-find-file-at-mouse)
1597 1735
1598(require 'font-lock) 1736(require 'font-lock)
1599 1737
1600(defconst org-non-link-chars "\t\n\r|") 1738(defconst org-non-link-chars "\t\n\r|<>\000")
1601(defconst org-link-regexp 1739(defconst org-link-regexp
1602 (if org-allow-space-in-links 1740 (if org-allow-space-in-links
1603 (concat 1741 (concat
1604 "\\(https?\\|ftp\\|mailto|\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^" org-non-link-chars "]+[^ " org-non-link-chars "]\\)") 1742 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^" org-non-link-chars "]+[^ " org-non-link-chars "]\\)")
1605 (concat 1743 (concat
1606 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^ " org-non-link-chars "]+\\)") 1744 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^ " org-non-link-chars "]+\\)")
1607 ) 1745 )
1608 "Regular expression for matching links.") 1746 "Regular expression for matching links.")
1747(defconst org-link-maybe-angles-regexp
1748 (concat "<?\\(" org-link-regexp "\\)>?")
1749 "Matches a link and optionally surrounding angle brackets.")
1750(defconst org-protected-link-regexp
1751 (concat "\000" org-link-regexp "\000")
1752 "Matches a link and optionally surrounding angle brackets.")
1753
1609(defconst org-ts-lengths 1754(defconst org-ts-lengths
1610 (cons (length (format-time-string (car org-time-stamp-formats))) 1755 (cons (length (format-time-string (car org-time-stamp-formats)))
1611 (length (format-time-string (cdr org-time-stamp-formats)))) 1756 (length (format-time-string (cdr org-time-stamp-formats))))
@@ -1650,37 +1795,37 @@ The following commands are available:
1650(defun org-set-font-lock-defaults () 1795(defun org-set-font-lock-defaults ()
1651 (let ((org-font-lock-extra-keywords 1796 (let ((org-font-lock-extra-keywords
1652 (list 1797 (list
1653 '(org-activate-links (0 'org-link-face)) 1798 '(org-activate-links (0 'org-link))
1654 '(org-activate-dates (0 'org-link-face)) 1799 '(org-activate-dates (0 'org-link))
1655 (list (concat "^\\*+[ \t]*" org-not-done-regexp) 1800 (list (concat "^\\*+[ \t]*" org-not-done-regexp)
1656 '(1 'org-warning-face t)) 1801 '(1 'org-warning t))
1657 (list (concat "\\[#[A-Z]\\]") '(0 'org-warning-face t)) 1802 (list (concat "\\[#[A-Z]\\]") '(0 'org-warning t))
1658 (list (concat "\\<" org-deadline-string) '(0 'org-warning-face t)) 1803 (list (concat "\\<" org-deadline-string) '(0 'org-warning t))
1659 (list (concat "\\<" org-scheduled-string) '(0 'org-warning-face t)) 1804 (list (concat "\\<" org-scheduled-string) '(0 'org-warning t))
1660 ;; '("\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)" 1805 ;; '("\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)"
1661 ;; (3 'bold)) 1806 ;; (3 'bold))
1662 ;; '("\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)" 1807 ;; '("\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)"
1663 ;; (3 'italic)) 1808 ;; (3 'italic))
1664 ;; '("\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)" 1809 ;; '("\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)"
1665 ;; (3 'underline)) 1810 ;; (3 'underline))
1666 '("\\<FIXME\\>" (0 'org-warning-face t)) 1811 '("\\<FIXME\\>" (0 'org-warning t))
1667 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string "\\)\\>") 1812 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string "\\)\\>")
1668 '(1 'org-warning-face t)) 1813 '(1 'org-warning t))
1669 '("^#.*" (0 'font-lock-comment-face t)) 1814 '("^#.*" (0 'font-lock-comment-face t))
1670 (if org-fontify-done-headline 1815 (if org-fontify-done-headline
1671 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\(.*\\)\\>") 1816 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\(.*\\)\\>")
1672 '(1 'org-done-face t) '(2 'org-headline-done-face t)) 1817 '(1 'org-done t) '(2 'org-headline-done t))
1673 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\>") 1818 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\>")
1674 '(1 'org-done-face t))) 1819 '(1 'org-done t)))
1675 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" 1820 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
1676 (1 'org-table-face t)) 1821 (1 'org-table t))
1677 '("^[ \t]*\\(:.*\\)" (1 'org-table-face t))))) 1822 '("^[ \t]*\\(:.*\\)" (1 'org-table t)))))
1678 (set (make-local-variable 'org-font-lock-keywords) 1823 (set (make-local-variable 'org-font-lock-keywords)
1679 (append 1824 (append
1680 (if org-noutline-p ; FIXME: I am not sure if eval will work 1825 (if org-noutline-p ; FIXME: I am not sure if eval will work
1681 ; on XEmacs if noutline is ever ported 1826 ; on XEmacs if noutline is ever ported
1682 '((eval . (list "^\\(\\*+\\).*" 1827 '((eval . (list "^\\(\\*+\\).*"
1683 0 '(nth 1828 0 '(nth
1684 (% (- (match-end 1) (match-beginning 1) 1) 1829 (% (- (match-end 1) (match-beginning 1) 1)
1685 org-n-levels) 1830 org-n-levels)
1686 org-level-faces) 1831 org-level-faces)
@@ -1694,7 +1839,7 @@ The following commands are available:
1694 (set (make-local-variable 'font-lock-defaults) 1839 (set (make-local-variable 'font-lock-defaults)
1695 '(org-font-lock-keywords t nil nil backward-paragraph)) 1840 '(org-font-lock-keywords t nil nil backward-paragraph))
1696 (kill-local-variable 'font-lock-keywords) nil)) 1841 (kill-local-variable 'font-lock-keywords) nil))
1697 1842
1698(defun org-unfontify-region (beg end &optional maybe_loudly) 1843(defun org-unfontify-region (beg end &optional maybe_loudly)
1699 "Remove fontification and activation overlays from links." 1844 "Remove fontification and activation overlays from links."
1700 (font-lock-default-unfontify-region beg end) 1845 (font-lock-default-unfontify-region beg end)
@@ -1885,12 +2030,12 @@ Optional argument N means, put the headline into the Nth line of the window."
1885(let ((cmds '(isearch-forward isearch-backward)) cmd) 2030(let ((cmds '(isearch-forward isearch-backward)) cmd)
1886 (while (setq cmd (pop cmds)) 2031 (while (setq cmd (pop cmds))
1887 (substitute-key-definition cmd cmd org-goto-map global-map))) 2032 (substitute-key-definition cmd cmd org-goto-map global-map)))
1888(define-key org-goto-map [(return)] 'org-goto-ret) 2033(define-key org-goto-map "\C-m" 'org-goto-ret)
1889(define-key org-goto-map [(left)] 'org-goto-left) 2034(define-key org-goto-map [(left)] 'org-goto-left)
1890(define-key org-goto-map [(right)] 'org-goto-right) 2035(define-key org-goto-map [(right)] 'org-goto-right)
1891(define-key org-goto-map [(?q)] 'org-goto-quit) 2036(define-key org-goto-map [(?q)] 'org-goto-quit)
1892(define-key org-goto-map [(control ?g)] 'org-goto-quit) 2037(define-key org-goto-map [(control ?g)] 'org-goto-quit)
1893(define-key org-goto-map [(tab)] 'org-cycle) 2038(define-key org-goto-map "\C-i" 'org-cycle)
1894(define-key org-goto-map [(down)] 'outline-next-visible-heading) 2039(define-key org-goto-map [(down)] 'outline-next-visible-heading)
1895(define-key org-goto-map [(up)] 'outline-previous-visible-heading) 2040(define-key org-goto-map [(up)] 'outline-previous-visible-heading)
1896(define-key org-goto-map "n" 'outline-next-visible-heading) 2041(define-key org-goto-map "n" 'outline-next-visible-heading)
@@ -2094,7 +2239,7 @@ in the region."
2094 (org-back-to-heading t) 2239 (org-back-to-heading t)
2095 (let* ((level (save-match-data (funcall outline-level))) 2240 (let* ((level (save-match-data (funcall outline-level)))
2096 (up-head (make-string (1- level) ?*))) 2241 (up-head (make-string (1- level) ?*)))
2097 (if (= level 1) (error "Cannot promote to level 0. UNDO to recover.")) 2242 (if (= level 1) (error "Cannot promote to level 0. UNDO to recover"))
2098 (replace-match up-head nil t) 2243 (replace-match up-head nil t)
2099 (if org-adapt-indentation 2244 (if org-adapt-indentation
2100 (org-fixup-indentation "^ " "" "^ ?\\S-")))) 2245 (org-fixup-indentation "^ " "" "^ ?\\S-"))))
@@ -2275,15 +2420,21 @@ If optional TREE is given, use this text instead of the kill ring."
2275 (- (match-end 0) (match-beginning 0))) 2420 (- (match-end 0) (match-beginning 0)))
2276 (t nil))) 2421 (t nil)))
2277 (previous-level (save-excursion 2422 (previous-level (save-excursion
2278 (outline-previous-visible-heading 1) 2423 (condition-case nil
2279 (if (looking-at re) 2424 (progn
2280 (- (match-end 0) (match-beginning 0)) 2425 (outline-previous-visible-heading 1)
2281 1))) 2426 (if (looking-at re)
2427 (- (match-end 0) (match-beginning 0))
2428 1))
2429 (error 1))))
2282 (next-level (save-excursion 2430 (next-level (save-excursion
2283 (outline-next-visible-heading 1) 2431 (condition-case nil
2284 (if (looking-at re) 2432 (progn
2285 (- (match-end 0) (match-beginning 0)) 2433 (outline-next-visible-heading 1)
2286 1))) 2434 (if (looking-at re)
2435 (- (match-end 0) (match-beginning 0))
2436 1))
2437 (error 1))))
2287 (new-level (or force-level (max previous-level next-level))) 2438 (new-level (or force-level (max previous-level next-level)))
2288 (shift (if (or (= old-level -1) 2439 (shift (if (or (= old-level -1)
2289 (= new-level -1) 2440 (= new-level -1)
@@ -2342,6 +2493,102 @@ If optional TXT is given, check this string instead of the current kill."
2342 (throw 'exit nil))) 2493 (throw 'exit nil)))
2343 t)))) 2494 t))))
2344 2495
2496(defun org-archive-subtree ()
2497 "Move the current subtree to the archive.
2498The archive can be a certain top-level heading in the current file, or in
2499a different file. The tree will be moved to that location, the subtree
2500heading be marked DONE, and the current time will be added."
2501 (interactive)
2502 ;; Save all relevant TODO keyword-relatex variables
2503 (let ((tr-org-todo-line-regexp org-todo-line-regexp) ; keep despite compiler
2504 (tr-org-todo-keywords org-todo-keywords)
2505 (tr-org-todo-interpretation org-todo-interpretation)
2506 (tr-org-done-string org-done-string)
2507 (tr-org-todo-regexp org-todo-regexp)
2508 (tr-org-todo-line-regexp org-todo-line-regexp)
2509 (this-buffer (current-buffer))
2510 file heading buffer level newfile-p)
2511 (if (string-match "\\(.*\\)::\\(.*\\)" org-archive-location)
2512 (progn
2513 (setq file (format (match-string 1 org-archive-location)
2514 (file-name-nondirectory (buffer-file-name)))
2515 heading (match-string 2 org-archive-location)))
2516 (error "Invalid `org-archive-location'"))
2517 (if (> (length file) 0)
2518 (setq newfile-p (not (file-exists-p file))
2519 buffer (find-file-noselect file))
2520 (setq buffer (current-buffer)))
2521 (unless buffer
2522 (error "Cannot access file \"%s\"" file))
2523 (if (and (> (length heading) 0)
2524 (string-match "^\\*+" heading))
2525 (setq level (match-end 0))
2526 (setq heading nil level 0))
2527 (save-excursion
2528 (org-copy-subtree) ; We first only copy, in case something goes wrong
2529 (set-buffer buffer)
2530 ;; Enforce org-mode for the archive buffer
2531 (if (not (eq major-mode 'org-mode))
2532 ;; Force the mode for future visits.
2533 (let ((org-insert-mode-line-in-empty-file t))
2534 (call-interactively 'org-mode)))
2535 (when newfile-p
2536 (goto-char (point-max))
2537 (insert (format "\nArchived entries from file %s\n\n"
2538 (buffer-file-name this-buffer))))
2539 ;; Force the TODO keywords of the original buffer
2540 (let ((org-todo-line-regexp tr-org-todo-line-regexp)
2541 (org-todo-keywords tr-org-todo-keywords)
2542 (org-todo-interpretation tr-org-todo-interpretation)
2543 (org-done-string tr-org-done-string)
2544 (org-todo-regexp tr-org-todo-regexp)
2545 (org-todo-line-regexp tr-org-todo-line-regexp))
2546 (goto-char (point-min))
2547 (if heading
2548 (progn
2549 (if (re-search-forward
2550 (concat "\\(^\\|\r\\)"
2551 (regexp-quote heading) "[ \t]*\\($\\|\r\\)")
2552 nil t)
2553 (goto-char (match-end 0))
2554 ;; Heading not found, just insert it at the end
2555 (goto-char (point-max))
2556 (or (bolp) (insert "\n"))
2557 (insert "\n" heading "\n")
2558 (end-of-line 0))
2559 ;; Make the heading visible, and the following as well
2560 (let ((org-show-following-heading t)) (org-show-hierarchy-above))
2561 (if (re-search-forward
2562 (concat "^" (regexp-quote (make-string level ?*)) "[ \t]")
2563 nil t)
2564 (progn (goto-char (match-beginning 0)) (insert "\n")
2565 (beginning-of-line 0))
2566 (goto-char (point-max)) (insert "\n")))
2567 (goto-char (point-max)) (insert "\n"))
2568 ;; Paste
2569 (org-paste-subtree (1+ level))
2570 ;; Mark the entry as done, i.e. set to last work in org-todo-keywords
2571 (if org-archive-mark-done
2572 (org-todo (length org-todo-keywords)))
2573 ;; Move cursor to right after the TODO keyword
2574 (when org-archive-stamp-time
2575 (beginning-of-line 1)
2576 (looking-at org-todo-line-regexp)
2577 (goto-char (or (match-end 2) (match-beginning 3)))
2578 (insert "(" (format-time-string (cdr org-time-stamp-formats)
2579 (current-time))
2580 ")"))
2581 ;; Save the buffer, if it is not the same buffer.
2582 (if (not (eq this-buffer buffer)) (save-buffer))))
2583 ;; Here we are back in the original buffer. Everything seems to have
2584 ;; worked. So now cut the tree and finish up.
2585 (org-cut-subtree)
2586 (if (looking-at "[ \t]*$") (kill-line))
2587 (message "Subtree archived %s"
2588 (if (eq this-buffer buffer)
2589 (concat "under heading: " heading)
2590 (concat "in file: " (abbreviate-file-name file))))))
2591
2345;;; Completion 2592;;; Completion
2346 2593
2347(defun org-complete (&optional arg) 2594(defun org-complete (&optional arg)
@@ -2370,11 +2617,11 @@ At all other locations, this simply calls `ispell-complete-word'."
2370 (table (cond 2617 (table (cond
2371 (opt 2618 (opt
2372 (setq type :opt) 2619 (setq type :opt)
2373 (mapcar (lambda (x) 2620 (mapcar (lambda (x)
2374 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x) 2621 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
2375 (cons (match-string 2 x) (match-string 1 x))) 2622 (cons (match-string 2 x) (match-string 1 x)))
2376 (org-split-string (org-get-current-options) "\n"))) 2623 (org-split-string (org-get-current-options) "\n")))
2377 (texp 2624 (texp
2378 (setq type :tex) 2625 (setq type :tex)
2379 org-html-entities) 2626 org-html-entities)
2380 ((string-match "\\`\\*+[ \t]*\\'" 2627 ((string-match "\\`\\*+[ \t]*\\'"
@@ -2384,7 +2631,7 @@ At all other locations, this simply calls `ispell-complete-word'."
2384 (t (progn (ispell-complete-word arg) (throw 'exit nil))))) 2631 (t (progn (ispell-complete-word arg) (throw 'exit nil)))))
2385 (completion (try-completion pattern table))) 2632 (completion (try-completion pattern table)))
2386 (cond ((eq completion t) 2633 (cond ((eq completion t)
2387 (if (equal type :opt) 2634 (if (equal type :opt)
2388 (insert (substring (cdr (assoc (upcase pattern) table)) 2635 (insert (substring (cdr (assoc (upcase pattern) table))
2389 (length pattern))))) 2636 (length pattern)))))
2390 ((null completion) 2637 ((null completion)
@@ -2392,7 +2639,7 @@ At all other locations, this simply calls `ispell-complete-word'."
2392 (ding)) 2639 (ding))
2393 ((not (string= pattern completion)) 2640 ((not (string= pattern completion))
2394 (delete-region beg end) 2641 (delete-region beg end)
2395 (if (string-match " +$" completion) 2642 (if (string-match " +$" completion)
2396 (setq completion (replace-match "" t t completion))) 2643 (setq completion (replace-match "" t t completion)))
2397 (insert completion) 2644 (insert completion)
2398 (if (get-buffer-window "*Completions*") 2645 (if (get-buffer-window "*Completions*")
@@ -2629,9 +2876,9 @@ ACTION can be set, up, or down."
2629 (save-match-data 2876 (save-match-data
2630 (if (not (string-match org-priority-regexp s)) 2877 (if (not (string-match org-priority-regexp s))
2631 (* 1000 (- org-lowest-priority org-default-priority)) 2878 (* 1000 (- org-lowest-priority org-default-priority))
2632 (* 1000 (- org-lowest-priority 2879 (* 1000 (- org-lowest-priority
2633 (string-to-char (match-string 2 s))))))) 2880 (string-to-char (match-string 2 s)))))))
2634 2881
2635;;; Timestamps 2882;;; Timestamps
2636 2883
2637(defvar org-last-changed-timestamp nil) 2884(defvar org-last-changed-timestamp nil)
@@ -2663,7 +2910,7 @@ at the cursor, it will be modified."
2663 (setq time (let ((this-command this-command)) 2910 (setq time (let ((this-command this-command))
2664 (org-read-date arg 'totime))) 2911 (org-read-date arg 'totime)))
2665 (and (org-at-timestamp-p) (replace-match 2912 (and (org-at-timestamp-p) (replace-match
2666 (setq org-last-changed-timestamp 2913 (setq org-last-changed-timestamp
2667 (format-time-string fmt time)) 2914 (format-time-string fmt time))
2668 t t)) 2915 t t))
2669 (message "Timestamp updated")) 2916 (message "Timestamp updated"))
@@ -2693,8 +2940,8 @@ but this can be configured with the variables `parse-time-months' and
2693 2940
2694While prompting, a calendar is popped up - you can also select the 2941While prompting, a calendar is popped up - you can also select the
2695date with the mouse (button 1). The calendar shows a period of three 2942date with the mouse (button 1). The calendar shows a period of three
2696month. To scroll it to other months, use the keys `>' and `<'. 2943month. To scroll it to other months, use the keys `>' and `<'.
2697If you don't like the calendar, turn it off with 2944If you don't like the calendar, turn it off with
2698 \(setq org-popup-calendar-for-date-prompt nil). 2945 \(setq org-popup-calendar-for-date-prompt nil).
2699 2946
2700With optional argument TO-TIME, the date will immediately be converted 2947With optional argument TO-TIME, the date will immediately be converted
@@ -2708,7 +2955,7 @@ used to insert the time stamp into the buffer to include the time."
2708 ;; Default time is either today, or, when entering a range, 2955 ;; Default time is either today, or, when entering a range,
2709 ;; the range start. 2956 ;; the range start.
2710 (if (save-excursion 2957 (if (save-excursion
2711 (re-search-backward 2958 (re-search-backward
2712 (concat org-ts-regexp "--\\=") 2959 (concat org-ts-regexp "--\\=")
2713 (- (point) 20) t)) 2960 (- (point) 20) t))
2714 (apply 2961 (apply
@@ -2819,7 +3066,7 @@ This is used by `org-read-date' in a temporary keymap for the calendar buffer."
2819 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) 3066 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
2820 (setq ans1 (format-time-string "%Y-%m-%d" time))) 3067 (setq ans1 (format-time-string "%Y-%m-%d" time)))
2821 (if (active-minibuffer-window) (exit-minibuffer)))) 3068 (if (active-minibuffer-window) (exit-minibuffer))))
2822 3069
2823(defun org-check-deadlines (ndays) 3070(defun org-check-deadlines (ndays)
2824 "Check if there are any deadlines due or past due. 3071 "Check if there are any deadlines due or past due.
2825A deadline is considered due if it happens within `org-deadline-warning-days' 3072A deadline is considered due if it happens within `org-deadline-warning-days'
@@ -2859,7 +3106,7 @@ days in order to avoid rounding problems."
2859 (goto-char (point-at-bol)) 3106 (goto-char (point-at-bol))
2860 (re-search-forward org-tr-regexp (point-at-eol) t)) 3107 (re-search-forward org-tr-regexp (point-at-eol) t))
2861 (if (not (org-at-date-range-p)) 3108 (if (not (org-at-date-range-p))
2862 (error "Not at a time-stamp range, and none found in current line."))) 3109 (error "Not at a time-stamp range, and none found in current line")))
2863 (let* ((ts1 (match-string 1)) 3110 (let* ((ts1 (match-string 1))
2864 (ts2 (match-string 2)) 3111 (ts2 (match-string 2))
2865 (havetime (or (> (length ts1) 15) (> (length ts2) 15))) 3112 (havetime (or (> (length ts1) 15) (> (length ts2) 15)))
@@ -3092,6 +3339,7 @@ If there is already a time stamp at the cursor position, update it."
3092(defvar org-agenda-follow-mode nil) 3339(defvar org-agenda-follow-mode nil)
3093(defvar org-agenda-buffer-name "*Org Agenda*") 3340(defvar org-agenda-buffer-name "*Org Agenda*")
3094(defvar org-agenda-redo-command nil) 3341(defvar org-agenda-redo-command nil)
3342(defvar org-agenda-mode-hook nil)
3095 3343
3096;;;###autoload 3344;;;###autoload
3097(defun org-agenda-mode () 3345(defun org-agenda-mode ()
@@ -3110,27 +3358,29 @@ The following commands are available:
3110 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local) 3358 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
3111 (add-hook 'pre-command-hook 'org-unhighlight nil 'local) 3359 (add-hook 'pre-command-hook 'org-unhighlight nil 'local)
3112 (setq org-agenda-follow-mode nil) 3360 (setq org-agenda-follow-mode nil)
3113 (easy-menu-change 3361 (easy-menu-change
3114 '("Agenda") "Agenda Files" 3362 '("Agenda") "Agenda Files"
3115 (append 3363 (append
3116 (list 3364 (list
3117 ["Edit File List" (customize-variable 'org-agenda-files) t] 3365 ["Edit File List" (customize-variable 'org-agenda-files) t]
3118 "--") 3366 "--")
3119 (mapcar 'org-file-menu-entry org-agenda-files))) 3367 (mapcar 'org-file-menu-entry org-agenda-files)))
3120 (org-agenda-set-mode-name) 3368 (org-agenda-set-mode-name)
3121 (run-mode-hooks 'org-agenda-mode-hook)) 3369 (apply
3370 (if (fboundp 'run-mode-hooks) 'run-mode-hooks 'run-hooks)
3371 org-agenda-mode-hook))
3122 3372
3123(define-key org-agenda-mode-map [(tab)] 'org-agenda-goto) 3373(define-key org-agenda-mode-map "\C-i" 'org-agenda-goto)
3124(define-key org-agenda-mode-map [(return)] 'org-agenda-switch-to) 3374(define-key org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
3125(define-key org-agenda-mode-map " " 'org-agenda-show) 3375(define-key org-agenda-mode-map " " 'org-agenda-show)
3126(define-key org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo) 3376(define-key org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
3127(define-key org-agenda-mode-map "o" 'delete-other-windows) 3377(define-key org-agenda-mode-map "o" 'delete-other-windows)
3128(define-key org-agenda-mode-map "l" 'org-agenda-recenter) 3378(define-key org-agenda-mode-map "l" 'org-agenda-recenter)
3129(define-key org-agenda-mode-map "t" 'org-agenda-todo) 3379(define-key org-agenda-mode-map "t" 'org-agenda-todo)
3130(define-key org-agenda-mode-map "." 'org-agenda-goto-today) 3380(define-key org-agenda-mode-map "." 'org-agenda-goto-today)
3131(define-key org-agenda-mode-map "w" 'org-agenda-toggle-week-view) 3381(define-key org-agenda-mode-map "w" 'org-agenda-toggle-week-view)
3132(define-key org-agenda-mode-map [(shift right)] 'org-agenda-date-later) 3382(define-key org-agenda-mode-map (org-key 'S-right) 'org-agenda-date-later)
3133(define-key org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier) 3383(define-key org-agenda-mode-map (org-key 'S-left) 'org-agenda-date-earlier)
3134 3384
3135(define-key org-agenda-mode-map ">" 'org-agenda-date-prompt) 3385(define-key org-agenda-mode-map ">" 'org-agenda-date-prompt)
3136(let ((l '(1 2 3 4 5 6 7 8 9 0))) 3386(let ((l '(1 2 3 4 5 6 7 8 9 0)))
@@ -3164,15 +3414,15 @@ The following commands are available:
3164(define-key org-agenda-mode-map "H" 'org-agenda-holidays) 3414(define-key org-agenda-mode-map "H" 'org-agenda-holidays)
3165(define-key org-agenda-mode-map "+" 'org-agenda-priority-up) 3415(define-key org-agenda-mode-map "+" 'org-agenda-priority-up)
3166(define-key org-agenda-mode-map "-" 'org-agenda-priority-down) 3416(define-key org-agenda-mode-map "-" 'org-agenda-priority-down)
3167(define-key org-agenda-mode-map [(shift up)] 'org-agenda-priority-up) 3417(define-key org-agenda-mode-map (org-key 'S-up) 'org-agenda-priority-up)
3168(define-key org-agenda-mode-map [(shift down)] 'org-agenda-priority-down) 3418(define-key org-agenda-mode-map (org-key 'S-down) 'org-agenda-priority-down)
3169(define-key org-agenda-mode-map [(right)] 'org-agenda-later) 3419(define-key org-agenda-mode-map [(right)] 'org-agenda-later)
3170(define-key org-agenda-mode-map [(left)] 'org-agenda-earlier) 3420(define-key org-agenda-mode-map [(left)] 'org-agenda-earlier)
3171 3421
3172(defvar org-agenda-keymap (copy-keymap org-agenda-mode-map) 3422(defvar org-agenda-keymap (copy-keymap org-agenda-mode-map)
3173 "Local keymap for agenda entries from Org-mode.") 3423 "Local keymap for agenda entries from Org-mode.")
3174 3424
3175(define-key org-agenda-keymap 3425(define-key org-agenda-keymap
3176 (if org-xemacs-p [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse) 3426 (if org-xemacs-p [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse)
3177(define-key org-agenda-keymap 3427(define-key org-agenda-keymap
3178 (if org-xemacs-p [(button3)] [(mouse-3)]) 'org-agenda-show-mouse) 3428 (if org-xemacs-p [(button3)] [(mouse-3)]) 'org-agenda-show-mouse)
@@ -3184,7 +3434,7 @@ The following commands are available:
3184 ["Show" org-agenda-show t] 3434 ["Show" org-agenda-show t]
3185 ["Go To (other window)" org-agenda-goto t] 3435 ["Go To (other window)" org-agenda-goto t]
3186 ["Go To (one window)" org-agenda-switch-to t] 3436 ["Go To (one window)" org-agenda-switch-to t]
3187 ["Follow Mode" org-agenda-follow-mode 3437 ["Follow Mode" org-agenda-follow-mode
3188 :style toggle :selected org-agenda-follow-mode :active t] 3438 :style toggle :selected org-agenda-follow-mode :active t]
3189 "--" 3439 "--"
3190 ["Cycle TODO" org-agenda-todo t] 3440 ["Cycle TODO" org-agenda-todo t]
@@ -3302,7 +3552,7 @@ dates."
3302 (org-respect-restriction t) 3552 (org-respect-restriction t)
3303 (past t) 3553 (past t)
3304 s e rtn d) 3554 s e rtn d)
3305 (setq org-agenda-redo-command 3555 (setq org-agenda-redo-command
3306 (list 'progn 3556 (list 'progn
3307 (list 'switch-to-buffer-other-window (current-buffer)) 3557 (list 'switch-to-buffer-other-window (current-buffer))
3308 (list 'org-timeline include-all))) 3558 (list 'org-timeline include-all)))
@@ -3311,7 +3561,7 @@ dates."
3311 (setq day-numbers (delq nil (mapcar (lambda(x) 3561 (setq day-numbers (delq nil (mapcar (lambda(x)
3312 (if (>= x today) x nil)) 3562 (if (>= x today) x nil))
3313 day-numbers)))) 3563 day-numbers))))
3314 (switch-to-buffer-other-window 3564 (switch-to-buffer-other-window
3315 (get-buffer-create org-agenda-buffer-name)) 3565 (get-buffer-create org-agenda-buffer-name))
3316 (setq buffer-read-only nil) 3566 (setq buffer-read-only nil)
3317 (erase-buffer) 3567 (erase-buffer)
@@ -3326,7 +3576,7 @@ dates."
3326 (setq date (calendar-gregorian-from-absolute d)) 3576 (setq date (calendar-gregorian-from-absolute d))
3327 (setq s (point)) 3577 (setq s (point))
3328 (if dotodo 3578 (if dotodo
3329 (setq rtn (org-agenda-get-day-entries 3579 (setq rtn (org-agenda-get-day-entries
3330 entry date :todo :timestamp)) 3580 entry date :todo :timestamp))
3331 (setq rtn (org-agenda-get-day-entries entry date :timestamp))) 3581 (setq rtn (org-agenda-get-day-entries entry date :timestamp)))
3332 (if (or rtn (equal d today)) 3582 (if (or rtn (equal d today))
@@ -3336,7 +3586,7 @@ dates."
3336 (calendar-month-name (extract-calendar-month date)) " " 3586 (calendar-month-name (extract-calendar-month date)) " "
3337 (number-to-string (extract-calendar-year date)) "\n") 3587 (number-to-string (extract-calendar-year date)) "\n")
3338 (put-text-property s (1- (point)) 'face 3588 (put-text-property s (1- (point)) 'face
3339 'org-link-face) 3589 'org-link)
3340 (if (equal d today) 3590 (if (equal d today)
3341 (put-text-property s (1- (point)) 'org-today t)) 3591 (put-text-property s (1- (point)) 'org-today t))
3342 (insert (org-finalize-agenda-entries rtn) "\n") 3592 (insert (org-finalize-agenda-entries rtn) "\n")
@@ -3382,7 +3632,7 @@ NDAYS defaults to `org-agenda-ndays'."
3382 (day-numbers (list start)) 3632 (day-numbers (list start))
3383 (inhibit-redisplay t) 3633 (inhibit-redisplay t)
3384 s e rtn rtnall file date d start-pos end-pos todayp nd) 3634 s e rtn rtnall file date d start-pos end-pos todayp nd)
3385 (setq org-agenda-redo-command 3635 (setq org-agenda-redo-command
3386 (list 'org-agenda include-all start-day ndays)) 3636 (list 'org-agenda include-all start-day ndays))
3387 ;; Make the list of days 3637 ;; Make the list of days
3388 (setq ndays (or ndays org-agenda-ndays) 3638 (setq ndays (or ndays org-agenda-ndays)
@@ -3394,7 +3644,7 @@ NDAYS defaults to `org-agenda-ndays'."
3394 (if (not (equal (current-buffer) (get-buffer org-agenda-buffer-name))) 3644 (if (not (equal (current-buffer) (get-buffer org-agenda-buffer-name)))
3395 (progn 3645 (progn
3396 (delete-other-windows) 3646 (delete-other-windows)
3397 (switch-to-buffer-other-window 3647 (switch-to-buffer-other-window
3398 (get-buffer-create org-agenda-buffer-name)))) 3648 (get-buffer-create org-agenda-buffer-name))))
3399 (setq buffer-read-only nil) 3649 (setq buffer-read-only nil)
3400 (erase-buffer) 3650 (erase-buffer)
@@ -3412,10 +3662,10 @@ NDAYS defaults to `org-agenda-ndays'."
3412 rtn (org-agenda-get-day-entries 3662 rtn (org-agenda-get-day-entries
3413 file date :todo)) 3663 file date :todo))
3414 (setq rtnall (append rtnall rtn)))) 3664 (setq rtnall (append rtnall rtn))))
3415 (when rtnall 3665 (when rtnall
3416 (insert "ALL CURRENTLY OPEN TODO ITEMS:\n") 3666 (insert "ALL CURRENTLY OPEN TODO ITEMS:\n")
3417 (add-text-properties (point-min) (1- (point)) 3667 (add-text-properties (point-min) (1- (point))
3418 (list 'face 'org-link-face)) 3668 (list 'face 'org-link))
3419 (insert (org-finalize-agenda-entries rtnall) "\n"))) 3669 (insert (org-finalize-agenda-entries rtnall) "\n")))
3420 (while (setq d (pop day-numbers)) 3670 (while (setq d (pop day-numbers))
3421 (setq date (calendar-gregorian-from-absolute d) 3671 (setq date (calendar-gregorian-from-absolute d)
@@ -3445,13 +3695,13 @@ NDAYS defaults to `org-agenda-ndays'."
3445 (calendar-month-name (extract-calendar-month date)) 3695 (calendar-month-name (extract-calendar-month date))
3446 (extract-calendar-year date))) 3696 (extract-calendar-year date)))
3447 (put-text-property s (1- (point)) 'face 3697 (put-text-property s (1- (point)) 'face
3448 'org-link-face) 3698 'org-link)
3449 (if rtnall (insert 3699 (if rtnall (insert
3450 (org-finalize-agenda-entries ;; FIXME: condition needed 3700 (org-finalize-agenda-entries ;; FIXME: condition needed
3451 (org-agenda-add-time-grid-maybe 3701 (org-agenda-add-time-grid-maybe
3452 rtnall nd todayp)) 3702 rtnall nd todayp))
3453 "\n")) 3703 "\n"))
3454 (put-text-property s (1- (point)) 'day d)))) 3704 (put-text-property s (1- (point)) 'day d))))
3455 (goto-char (point-min)) 3705 (goto-char (point-min))
3456 (setq buffer-read-only t) 3706 (setq buffer-read-only t)
3457 (if org-fit-agenda-window 3707 (if org-fit-agenda-window
@@ -3541,7 +3791,7 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
3541 (error "Not allowed")) 3791 (error "Not allowed"))
3542 (setq org-agenda-ndays 3792 (setq org-agenda-ndays
3543 (if (equal org-agenda-ndays 1) 7 1)) 3793 (if (equal org-agenda-ndays 1) 7 1))
3544 (org-agenda include-all-loc 3794 (org-agenda include-all-loc
3545 (or (get-text-property (point) 'day) 3795 (or (get-text-property (point) 'day)
3546 starting-day)) 3796 starting-day))
3547 (org-agenda-set-mode-name) 3797 (org-agenda-set-mode-name)
@@ -3556,7 +3806,7 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
3556 (if (not (re-search-forward "^\\S-" nil t arg)) 3806 (if (not (re-search-forward "^\\S-" nil t arg))
3557 (progn 3807 (progn
3558 (backward-char 1) 3808 (backward-char 1)
3559 (error "No next date after this line in this buffer."))) 3809 (error "No next date after this line in this buffer")))
3560 (goto-char (match-beginning 0))) 3810 (goto-char (match-beginning 0)))
3561 3811
3562(defun org-agenda-previous-date-line (&optional arg) 3812(defun org-agenda-previous-date-line (&optional arg)
@@ -3564,7 +3814,7 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
3564 (interactive "p") 3814 (interactive "p")
3565 (beginning-of-line 1) 3815 (beginning-of-line 1)
3566 (if (not (re-search-backward "^\\S-" nil t arg)) 3816 (if (not (re-search-backward "^\\S-" nil t arg))
3567 (error "No previous date before this line in this buffer."))) 3817 (error "No previous date before this line in this buffer")))
3568 3818
3569;; Initialize the highlight 3819;; Initialize the highlight
3570(defvar org-hl (funcall (if org-xemacs-p 'make-extent 'make-overlay) 1 1)) 3820(defvar org-hl (funcall (if org-xemacs-p 'make-extent 'make-overlay) 1 1))
@@ -3630,7 +3880,7 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
3630 "Get the (Emacs Calendar) diary entries for DATE." 3880 "Get the (Emacs Calendar) diary entries for DATE."
3631 (let* ((fancy-diary-buffer "*temporary-fancy-diary-buffer*") 3881 (let* ((fancy-diary-buffer "*temporary-fancy-diary-buffer*")
3632 (diary-display-hook '(fancy-diary-display)) 3882 (diary-display-hook '(fancy-diary-display))
3633 (list-diary-entries-hook 3883 (list-diary-entries-hook
3634 (cons 'org-diary-default-entry list-diary-entries-hook)) 3884 (cons 'org-diary-default-entry list-diary-entries-hook))
3635 entries 3885 entries
3636 (org-disable-diary t)) 3886 (org-disable-diary t))
@@ -3654,12 +3904,12 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
3654 (kill-buffer fancy-diary-buffer))) 3904 (kill-buffer fancy-diary-buffer)))
3655 (when entries 3905 (when entries
3656 (setq entries (org-split-string entries "\n")) 3906 (setq entries (org-split-string entries "\n"))
3657 (setq entries 3907 (setq entries
3658 (mapcar 3908 (mapcar
3659 (lambda (x) 3909 (lambda (x)
3660 (setq x (org-format-agenda-item "" x "Diary" 'time)) 3910 (setq x (org-format-agenda-item "" x "Diary" 'time))
3661 ;; Extend the text properties to the beginning of the line 3911 ;; Extend the text properties to the beginning of the line
3662 (add-text-properties 3912 (add-text-properties
3663 0 (length x) 3913 0 (length x)
3664 (text-properties-at (1- (length x)) x) 3914 (text-properties-at (1- (length x)) x)
3665 x) 3915 x)
@@ -3700,7 +3950,7 @@ date. Itt also removes lines that contain only whitespace."
3700 0 (length string) 3950 0 (length string)
3701 (list 'mouse-face 'highlight 3951 (list 'mouse-face 'highlight
3702 'keymap org-agenda-keymap 3952 'keymap org-agenda-keymap
3703 'help-echo 3953 'help-echo
3704 (format 3954 (format
3705 "mouse-2 or RET jump to diary file %s" 3955 "mouse-2 or RET jump to diary file %s"
3706 (abbreviate-file-name (buffer-file-name))) 3956 (abbreviate-file-name (buffer-file-name)))
@@ -3722,7 +3972,7 @@ Needed to avoid empty dates which mess up holiday display."
3722These are the files which are being checked for agenda entries. 3972These are the files which are being checked for agenda entries.
3723Optional argument FILE means, use this file instead of the current. 3973Optional argument FILE means, use this file instead of the current.
3724It is possible (but not recommended) to add this function to the 3974It is possible (but not recommended) to add this function to the
3725`org-mode-hook'." 3975`org-mode-hook'."
3726 (interactive) 3976 (interactive)
3727 (catch 'exit 3977 (catch 'exit
3728 (let* ((file (or file (buffer-file-name) 3978 (let* ((file (or file (buffer-file-name)
@@ -3737,7 +3987,7 @@ It is possible (but not recommended) to add this function to the
3737 org-agenda-files)))) 3987 org-agenda-files))))
3738 (if (not present) 3988 (if (not present)
3739 (progn 3989 (progn
3740 (setq org-agenda-files 3990 (setq org-agenda-files
3741 (cons afile org-agenda-files)) 3991 (cons afile org-agenda-files))
3742 ;; Make sure custom.el does not end up with Org-mode 3992 ;; Make sure custom.el does not end up with Org-mode
3743 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode)) 3993 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode))
@@ -3754,7 +4004,7 @@ Optional argument FILE means, use this file instead of the current."
3754 (let* ((file (or file (buffer-file-name))) 4004 (let* ((file (or file (buffer-file-name)))
3755 (true-file (file-truename file)) 4005 (true-file (file-truename file))
3756 (afile (abbreviate-file-name file)) 4006 (afile (abbreviate-file-name file))
3757 (files (delq nil (mapcar 4007 (files (delq nil (mapcar
3758 (lambda (x) 4008 (lambda (x)
3759 (if (equal true-file 4009 (if (equal true-file
3760 (file-truename x)) 4010 (file-truename x))
@@ -3839,7 +4089,7 @@ also be written as
3839 4089
3840The function expects the lisp variables `entry' and `date' to be provided 4090The function expects the lisp variables `entry' and `date' to be provided
3841by the caller, because this is how the calendar works. Don't use this 4091by the caller, because this is how the calendar works. Don't use this
3842function from a program - use `org-agenda-get-day-entries' instead." 4092function from a program - use `org-agenda-get-day-entries' instead."
3843 (org-agenda-maybe-reset-markers) 4093 (org-agenda-maybe-reset-markers)
3844 (org-compile-agenda-prefix-format org-agenda-prefix-format) 4094 (org-compile-agenda-prefix-format org-agenda-prefix-format)
3845 (setq args (or args '(:deadline :scheduled :timestamp))) 4095 (setq args (or args '(:deadline :scheduled :timestamp)))
@@ -3881,7 +4131,7 @@ the documentation of `org-diary'."
3881 (if (org-region-active-p) 4131 (if (org-region-active-p)
3882 ;; Respect a region to restrict search 4132 ;; Respect a region to restrict search
3883 (narrow-to-region (region-beginning) (region-end))) 4133 (narrow-to-region (region-beginning) (region-end)))
3884 ;; If we work for the calendar or many files, 4134 ;; If we work for the calendar or many files,
3885 ;; get rid of any restriction 4135 ;; get rid of any restriction
3886 (widen)) 4136 (widen))
3887 ;; The way we repeatedly append to `results' makes it O(n^2) :-( 4137 ;; The way we repeatedly append to `results' makes it O(n^2) :-(
@@ -3932,7 +4182,7 @@ the documentation of `org-diary'."
3932(defun org-agenda-get-todos () 4182(defun org-agenda-get-todos ()
3933 "Return the TODO information for agenda display." 4183 "Return the TODO information for agenda display."
3934 (let* ((props (list 'face nil 4184 (let* ((props (list 'face nil
3935 'done-face 'org-done-face 4185 'done-face 'org-done
3936 'mouse-face 'highlight 4186 'mouse-face 'highlight
3937 'keymap org-agenda-keymap 4187 'keymap org-agenda-keymap
3938 'help-echo 4188 'help-echo
@@ -3947,7 +4197,7 @@ the documentation of `org-diary'."
3947 (goto-char (match-beginning 1)) 4197 (goto-char (match-beginning 1))
3948 (setq marker (org-agenda-new-marker (point-at-bol)) 4198 (setq marker (org-agenda-new-marker (point-at-bol))
3949 txt (org-format-agenda-item "" (match-string 1)) 4199 txt (org-format-agenda-item "" (match-string 1))
3950 priority 4200 priority
3951 (+ (org-get-priority txt) 4201 (+ (org-get-priority txt)
3952 (if org-todo-kwd-priority-p 4202 (if org-todo-kwd-priority-p
3953 (- org-todo-kwd-max-priority -2 4203 (- org-todo-kwd-max-priority -2
@@ -4019,18 +4269,18 @@ the documentation of `org-diary'."
4019 (if deadlinep 4269 (if deadlinep
4020 (add-text-properties 4270 (add-text-properties
4021 0 (length txt) 4271 0 (length txt)
4022 (list 'face 4272 (list 'face
4023 (if donep 'org-done-face 'org-warning-face) 4273 (if donep 'org-done 'org-warning)
4024 'undone-face 'org-warning-face 4274 'undone-face 'org-warning
4025 'done-face 'org-done-face 4275 'done-face 'org-done
4026 'priority (+ 100 priority)) 4276 'priority (+ 100 priority))
4027 txt) 4277 txt)
4028 (if scheduledp 4278 (if scheduledp
4029 (add-text-properties 4279 (add-text-properties
4030 0 (length txt) 4280 0 (length txt)
4031 (list 'face 'org-scheduled-today-face 4281 (list 'face 'org-scheduled-today
4032 'undone-face 'org-scheduled-today-face 4282 'undone-face 'org-scheduled-today
4033 'done-face 'org-done-face 4283 'done-face 'org-done
4034 priority (+ 99 priority)) 4284 priority (+ 99 priority))
4035 txt) 4285 txt)
4036 (add-text-properties 4286 (add-text-properties
@@ -4079,19 +4329,19 @@ the documentation of `org-diary'."
4079 (setq txt org-agenda-no-heading-message)) 4329 (setq txt org-agenda-no-heading-message))
4080 (when txt 4330 (when txt
4081 (add-text-properties 4331 (add-text-properties
4082 0 (length txt) 4332 0 (length txt)
4083 (append 4333 (append
4084 (list 'org-marker (org-agenda-new-marker pos) 4334 (list 'org-marker (org-agenda-new-marker pos)
4085 'org-hd-marker (org-agenda-new-marker pos1) 4335 'org-hd-marker (org-agenda-new-marker pos1)
4086 'priority (+ (- 10 diff) (org-get-priority txt)) 4336 'priority (+ (- 10 diff) (org-get-priority txt))
4087 'face (cond ((<= diff 0) 'org-warning-face) 4337 'face (cond ((<= diff 0) 'org-warning)
4088 ((<= diff 5) 'org-scheduled-previously-face) 4338 ((<= diff 5) 'org-scheduled-previously)
4089 (t nil)) 4339 (t nil))
4090 'undone-face (cond 4340 'undone-face (cond
4091 ((<= diff 0) 'org-warning-face) 4341 ((<= diff 0) 'org-warning)
4092 ((<= diff 5) 'org-scheduled-previously-face) 4342 ((<= diff 5) 'org-scheduled-previously)
4093 (t nil)) 4343 (t nil))
4094 'done-face 'org-done-face) 4344 'done-face 'org-done)
4095 props) 4345 props)
4096 txt) 4346 txt)
4097 (push txt ee))))) 4347 (push txt ee)))))
@@ -4099,9 +4349,9 @@ the documentation of `org-diary'."
4099 4349
4100(defun org-agenda-get-scheduled () 4350(defun org-agenda-get-scheduled ()
4101 "Return the scheduled information for agenda display." 4351 "Return the scheduled information for agenda display."
4102 (let* ((props (list 'face 'org-scheduled-previously-face 4352 (let* ((props (list 'face 'org-scheduled-previously
4103 'undone-face 'org-scheduled-previously-face 4353 'undone-face 'org-scheduled-previously
4104 'done-face 'org-done-face 4354 'done-face 'org-done
4105 'mouse-face 'highlight 4355 'mouse-face 'highlight
4106 'keymap org-agenda-keymap 4356 'keymap org-agenda-keymap
4107 'help-echo 4357 'help-echo
@@ -4172,7 +4422,7 @@ the documentation of `org-diary'."
4172 (setq hdmarker (org-agenda-new-marker (match-end 1))) 4422 (setq hdmarker (org-agenda-new-marker (match-end 1)))
4173 (goto-char (match-end 1)) 4423 (goto-char (match-end 1))
4174 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)") 4424 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
4175 (setq txt (org-format-agenda-item 4425 (setq txt (org-format-agenda-item
4176 (format (if (= d1 d2) "" "(%d/%d): ") 4426 (format (if (= d1 d2) "" "(%d/%d): ")
4177 (1+ (- d0 d1)) (1+ (- d2 d1))) 4427 (1+ (- d0 d1)) (1+ (- d2 d1)))
4178 (match-string 1) nil (if (= d0 d1) timestr)))) 4428 (match-string 1) nil (if (= d0 d1) timestr))))
@@ -4254,7 +4504,7 @@ only the correctly processes TXT should be returned - this is used by
4254 (setq s0 (match-string 0 ts) 4504 (setq s0 (match-string 0 ts)
4255 s1 (match-string (if plain 1 2) ts) 4505 s1 (match-string (if plain 1 2) ts)
4256 s2 (match-string (if plain 8 4) ts)) 4506 s2 (match-string (if plain 8 4) ts))
4257 4507
4258 ;; If the times are in TXT (not in DOTIMES), and the prefix will list 4508 ;; If the times are in TXT (not in DOTIMES), and the prefix will list
4259 ;; them, we might want to remove them there to avoid duplication. 4509 ;; them, we might want to remove them there to avoid duplication.
4260 ;; The user can turn this off with a variable. 4510 ;; The user can turn this off with a variable.
@@ -4267,7 +4517,7 @@ only the correctly processes TXT should be returned - this is used by
4267 ;; Normalize the time(s) to 24 hour 4517 ;; Normalize the time(s) to 24 hour
4268 (if s1 (setq s1 (org-get-time-of-day s1 'string))) 4518 (if s1 (setq s1 (org-get-time-of-day s1 'string)))
4269 (if s2 (setq s2 (org-get-time-of-day s2 'string)))) 4519 (if s2 (setq s2 (org-get-time-of-day s2 'string))))
4270 4520
4271 ;; Create the final string 4521 ;; Create the final string
4272 (if noprefix 4522 (if noprefix
4273 (setq rtn txt) 4523 (setq rtn txt)
@@ -4279,7 +4529,7 @@ only the correctly processes TXT should be returned - this is used by
4279 category (if (symbolp category) (symbol-name category) category)) 4529 category (if (symbolp category) (symbol-name category) category))
4280 ;; Evaluate the compiled format 4530 ;; Evaluate the compiled format
4281 (setq rtn (concat (eval org-prefix-format-compiled) txt))) 4531 (setq rtn (concat (eval org-prefix-format-compiled) txt)))
4282 4532
4283 ;; And finally add the text properties 4533 ;; And finally add the text properties
4284 (add-text-properties 4534 (add-text-properties
4285 0 (length rtn) (list 'category (downcase category) 4535 0 (length rtn) (list 'category (downcase category)
@@ -4310,12 +4560,12 @@ only the correctly processes TXT should be returned - this is used by
4310 (while (setq time (pop gridtimes)) 4560 (while (setq time (pop gridtimes))
4311 (unless (and remove (member time have)) 4561 (unless (and remove (member time have))
4312 (setq time (int-to-string time)) 4562 (setq time (int-to-string time))
4313 (push (org-format-agenda-item 4563 (push (org-format-agenda-item
4314 nil string "" ;; FIXME: put a category? 4564 nil string "" ;; FIXME: put a category?
4315 (concat (substring time 0 -2) ":" (substring time -2))) 4565 (concat (substring time 0 -2) ":" (substring time -2)))
4316 new) 4566 new)
4317 (put-text-property 4567 (put-text-property
4318 1 (length (car new)) 'face 'org-time-grid-face (car new)))) 4568 1 (length (car new)) 'face 'org-time-grid (car new))))
4319 (if (member 'time-up org-agenda-sorting-strategy) 4569 (if (member 'time-up org-agenda-sorting-strategy)
4320 (append new list) 4570 (append new list)
4321 (append list new))))) 4571 (append list new)))))
@@ -4353,7 +4603,7 @@ If not found, return nil.
4353The optional STRING argument forces conversion into a 5 character wide string 4603The optional STRING argument forces conversion into a 5 character wide string
4354HH:MM." 4604HH:MM."
4355 (save-match-data 4605 (save-match-data
4356 (when 4606 (when
4357 (or 4607 (or
4358 (string-match 4608 (string-match
4359 "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)?\\> *" s) 4609 "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)?\\> *" s)
@@ -4401,6 +4651,7 @@ HH:MM."
4401 4651
4402(defun org-entries-lessp (a b) 4652(defun org-entries-lessp (a b)
4403 "Predicate for sorting agenda entries." 4653 "Predicate for sorting agenda entries."
4654 ;; The following variables will be used when the form is evaluated.
4404 (let* ((time-up (org-cmp-time a b)) 4655 (let* ((time-up (org-cmp-time a b))
4405 (time-down (if time-up (- time-up) nil)) 4656 (time-down (if time-up (- time-up) nil))
4406 (priority-up (org-cmp-priority a b)) 4657 (priority-up (org-cmp-priority a b))
@@ -4408,7 +4659,7 @@ HH:MM."
4408 (category-up (org-cmp-category a b)) 4659 (category-up (org-cmp-category a b))
4409 (category-down (if category-up (- category-up) nil)) 4660 (category-down (if category-up (- category-up) nil))
4410 (category-keep (if category-up +1 nil))) ; FIXME +1 or -1? 4661 (category-keep (if category-up +1 nil))) ; FIXME +1 or -1?
4411 (cdr (assoc 4662 (cdr (assoc
4412 (eval (cons 'or org-agenda-sorting-strategy)) 4663 (eval (cons 'or org-agenda-sorting-strategy))
4413 '((-1 . t) (1 . nil) (nil . nil)))))) 4664 '((-1 . t) (1 . nil) (nil . nil))))))
4414 4665
@@ -4423,7 +4674,7 @@ and by additional input from the age of a schedules or deadline entry."
4423(defun org-agenda-goto (&optional highlight) 4674(defun org-agenda-goto (&optional highlight)
4424 "Go to the Org-mode file which contains the item at point." 4675 "Go to the Org-mode file which contains the item at point."
4425 (interactive) 4676 (interactive)
4426 (let* ((marker (or (get-text-property (point) 'org-marker) 4677 (let* ((marker (or (get-text-property (point) 'org-marker)
4427 (org-agenda-error))) 4678 (org-agenda-error)))
4428 (buffer (marker-buffer marker)) 4679 (buffer (marker-buffer marker))
4429 (pos (marker-position marker))) 4680 (pos (marker-position marker)))
@@ -4440,7 +4691,7 @@ and by additional input from the age of a schedules or deadline entry."
4440(defun org-agenda-switch-to () 4691(defun org-agenda-switch-to ()
4441 "Go to the Org-mode file which contains the item at point." 4692 "Go to the Org-mode file which contains the item at point."
4442 (interactive) 4693 (interactive)
4443 (let* ((marker (or (get-text-property (point) 'org-marker) 4694 (let* ((marker (or (get-text-property (point) 'org-marker)
4444 (org-agenda-error))) 4695 (org-agenda-error)))
4445 (buffer (marker-buffer marker)) 4696 (buffer (marker-buffer marker))
4446 (pos (marker-position marker))) 4697 (pos (marker-position marker)))
@@ -4487,7 +4738,7 @@ and by additional input from the age of a schedules or deadline entry."
4487 (org-agenda-error))) 4738 (org-agenda-error)))
4488 4739
4489(defun org-agenda-error () 4740(defun org-agenda-error ()
4490 (error "Command not allowed in this line.")) 4741 (error "Command not allowed in this line"))
4491 4742
4492(defvar org-last-heading-marker (make-marker) 4743(defvar org-last-heading-marker (make-marker)
4493 "Marker pointing to the headline that last changed its TODO state 4744 "Marker pointing to the headline that last changed its TODO state
@@ -4554,7 +4805,7 @@ the new TODO state."
4554 (beginning-of-line 1) 4805 (beginning-of-line 1)
4555 (add-text-properties (point-at-bol) (point-at-eol) props) 4806 (add-text-properties (point-at-bol) (point-at-eol) props)
4556 (if fixface 4807 (if fixface
4557 (add-text-properties 4808 (add-text-properties
4558 (point-at-bol) (point-at-eol) 4809 (point-at-bol) (point-at-eol)
4559 (list 'face 4810 (list 'face
4560 (if org-last-todo-state-is-todo 4811 (if org-last-todo-state-is-todo
@@ -4651,7 +4902,7 @@ be used to request time specification in the time stamp."
4651All the standard commands work: block, weekly etc" 4902All the standard commands work: block, weekly etc"
4652 (interactive) 4903 (interactive)
4653 (require 'diary-lib) 4904 (require 'diary-lib)
4654 (let* ((char (progn 4905 (let* ((char (progn
4655 (message "Diary entry: [d]ay [w]eekly [m]onthly [y]early [a]nniversary [b]lock [c]yclic") 4906 (message "Diary entry: [d]ay [w]eekly [m]onthly [y]early [a]nniversary [b]lock [c]yclic")
4656 (read-char-exclusive))) 4907 (read-char-exclusive)))
4657 (cmd (cdr (assoc char 4908 (cmd (cdr (assoc char
@@ -4681,7 +4932,7 @@ All the standard commands work: block, weekly etc"
4681 (progn 4932 (progn
4682 (fset 'calendar-cursor-to-date 4933 (fset 'calendar-cursor-to-date
4683 (lambda (&optional error) 4934 (lambda (&optional error)
4684 (calendar-gregorian-from-absolute 4935 (calendar-gregorian-from-absolute
4685 (get-text-property point 'day)))) 4936 (get-text-property point 'day))))
4686 (call-interactively cmd)) 4937 (call-interactively cmd))
4687 (fset 'calendar-cursor-to-date oldf))))) 4938 (fset 'calendar-cursor-to-date oldf)))))
@@ -4704,7 +4955,7 @@ the cursor position."
4704 (progn 4955 (progn
4705 (fset 'calendar-cursor-to-date 4956 (fset 'calendar-cursor-to-date
4706 (lambda (&optional error) 4957 (lambda (&optional error)
4707 (calendar-gregorian-from-absolute 4958 (calendar-gregorian-from-absolute
4708 (get-text-property point 'day)))) 4959 (get-text-property point 'day))))
4709 (call-interactively cmd)) 4960 (call-interactively cmd))
4710 (fset 'calendar-cursor-to-date oldf)))) 4961 (fset 'calendar-cursor-to-date oldf))))
@@ -4754,7 +5005,7 @@ This is a command that has to be installed in `calendar-mode-map'."
4754 (unless day 5005 (unless day
4755 (error "Don't know which date to convert")) 5006 (error "Don't know which date to convert"))
4756 (setq date (calendar-gregorian-from-absolute day)) 5007 (setq date (calendar-gregorian-from-absolute day))
4757 (setq s (concat 5008 (setq s (concat
4758 "Gregorian: " (calendar-date-string date) "\n" 5009 "Gregorian: " (calendar-date-string date) "\n"
4759 "ISO: " (calendar-iso-date-string date) "\n" 5010 "ISO: " (calendar-iso-date-string date) "\n"
4760 "Day of Yr: " (calendar-day-of-year-string date) "\n" 5011 "Day of Yr: " (calendar-day-of-year-string date) "\n"
@@ -4801,7 +5052,8 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
4801 (let (type path line (pos (point))) 5052 (let (type path line (pos (point)))
4802 (save-excursion 5053 (save-excursion
4803 (skip-chars-backward 5054 (skip-chars-backward
4804 (if org-allow-space-in-links "^\t\n\r" "^ \t\n\r")) 5055 (concat (if org-allow-space-in-links "^" "^ ")
5056 org-non-link-chars))
4805 (if (re-search-forward 5057 (if (re-search-forward
4806 org-link-regexp 5058 org-link-regexp
4807 (save-excursion 5059 (save-excursion
@@ -4812,7 +5064,7 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
4812 (setq type (match-string 1) 5064 (setq type (match-string 1)
4813 path (match-string 2))) 5065 path (match-string 2)))
4814 (unless path 5066 (unless path
4815 (error "No link found.")) 5067 (error "No link found"))
4816 ;; Remove any trailing spaces in path 5068 ;; Remove any trailing spaces in path
4817 (if (string-match " +\\'" path) 5069 (if (string-match " +\\'" path)
4818 (setq path (replace-match "" t t path))) 5070 (setq path (replace-match "" t t path)))
@@ -4866,6 +5118,10 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
4866 5118
4867 ((string= type "shell") 5119 ((string= type "shell")
4868 (let ((cmd path)) 5120 (let ((cmd path))
5121 (while (string-match "@{" cmd)
5122 (setq cmd (replace-match "<" t t cmd)))
5123 (while (string-match "@}" cmd)
5124 (setq cmd (replace-match ">" t t cmd)))
4869 (if (or (not org-confirm-shell-links) 5125 (if (or (not org-confirm-shell-links)
4870 (yes-or-no-p (format "Execute \"%s\" in the shell? " cmd))) 5126 (yes-or-no-p (format "Execute \"%s\" in the shell? " cmd)))
4871 (shell-command cmd) 5127 (shell-command cmd)
@@ -4961,7 +5217,7 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
4961 (widen) 5217 (widen)
4962 (goto-char (point-max)) 5218 (goto-char (point-max))
4963 (if (re-search-backward 5219 (if (re-search-backward
4964 (concat "^Message-ID:\\s-+" (regexp-quote 5220 (concat "^Message-ID:\\s-+" (regexp-quote
4965 (or article ""))) 5221 (or article "")))
4966 nil t) 5222 nil t)
4967 (rmail-what-message)))))) 5223 (rmail-what-message))))))
@@ -4997,7 +5253,7 @@ If the file does not exist, an error is thrown."
4997 (cdr (assoc t apps))))) 5253 (cdr (assoc t apps)))))
4998 (cond 5254 (cond
4999 ((and (stringp cmd) (not (string-match "^\\s-*$" cmd))) 5255 ((and (stringp cmd) (not (string-match "^\\s-*$" cmd)))
5000 (setq cmd (format cmd file)) 5256 (setq cmd (format cmd (concat "\"" file "\"")))
5001 (save-window-excursion 5257 (save-window-excursion
5002 (shell-command (concat cmd " & &")))) 5258 (shell-command (concat cmd " & &"))))
5003 ((or (stringp cmd) 5259 ((or (stringp cmd)
@@ -5043,10 +5299,12 @@ For file links, arg negates `org-line-numbers-in-file-links'."
5043 (cond 5299 (cond
5044 5300
5045 ((eq major-mode 'bbdb-mode) 5301 ((eq major-mode 'bbdb-mode)
5046 (setq link (concat "bbdb:" 5302 (setq cpltxt (concat
5047 (or (bbdb-record-name (bbdb-current-record)) 5303 "bbdb:"
5048 (bbdb-record-company (bbdb-current-record)))))) 5304 (or (bbdb-record-name (bbdb-current-record))
5049 5305 (bbdb-record-company (bbdb-current-record))))
5306 link (org-make-link cpltxt)))
5307
5050 ((eq major-mode 'calendar-mode) 5308 ((eq major-mode 'calendar-mode)
5051 (let ((cd (calendar-cursor-to-date))) 5309 (let ((cd (calendar-cursor-to-date)))
5052 (setq link 5310 (setq link
@@ -5072,8 +5330,9 @@ For file links, arg negates `org-line-numbers-in-file-links'."
5072 folder) 5330 folder)
5073 (setq folder (replace-match "" t t folder))) 5331 (setq folder (replace-match "" t t folder)))
5074 (setq cpltxt (concat author " on: " subject)) 5332 (setq cpltxt (concat author " on: " subject))
5075 (setq link (concat cpltxt "\n " "vm:" folder 5333 (setq link (concat cpltxt "\n "
5076 "#" message-id))))) 5334 (org-make-link
5335 "vm:" folder "#" message-id))))))
5077 5336
5078 ((eq major-mode 'wl-summary-mode) 5337 ((eq major-mode 'wl-summary-mode)
5079 (let* ((msgnum (wl-summary-message-number)) 5338 (let* ((msgnum (wl-summary-message-number))
@@ -5084,8 +5343,10 @@ For file links, arg negates `org-line-numbers-in-file-links'."
5084 (author (wl-summary-line-from)) ; FIXME: how to get author name? 5343 (author (wl-summary-line-from)) ; FIXME: how to get author name?
5085 (subject "???")) ; FIXME: How to get subject of email? 5344 (subject "???")) ; FIXME: How to get subject of email?
5086 (setq cpltxt (concat author " on: " subject)) 5345 (setq cpltxt (concat author " on: " subject))
5087 (setq link (concat cpltxt "\n " "wl:" wl-summary-buffer-folder-name 5346 (setq link (concat cpltxt "\n "
5088 "#" message-id)))) 5347 (org-make-link
5348 "wl:" wl-summary-buffer-folder-name
5349 "#" message-id)))))
5089 5350
5090 ((eq major-mode 'rmail-mode) 5351 ((eq major-mode 'rmail-mode)
5091 (save-excursion 5352 (save-excursion
@@ -5096,8 +5357,9 @@ For file links, arg negates `org-line-numbers-in-file-links'."
5096 (author (mail-fetch-field "from")) 5357 (author (mail-fetch-field "from"))
5097 (subject (mail-fetch-field "subject"))) 5358 (subject (mail-fetch-field "subject")))
5098 (setq cpltxt (concat author " on: " subject)) 5359 (setq cpltxt (concat author " on: " subject))
5099 (setq link (concat cpltxt "\n " "rmail:" folder 5360 (setq link (concat cpltxt "\n "
5100 "#" message-id)))))) 5361 (org-make-link
5362 "rmail:" folder "#" message-id)))))))
5101 5363
5102 ((eq major-mode 'gnus-group-mode) 5364 ((eq major-mode 'gnus-group-mode)
5103 (let ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus 5365 (let ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus
@@ -5105,11 +5367,12 @@ For file links, arg negates `org-line-numbers-in-file-links'."
5105 ((fboundp 'gnus-group-name) 5367 ((fboundp 'gnus-group-name)
5106 (gnus-group-name)) 5368 (gnus-group-name))
5107 (t "???")))) 5369 (t "???"))))
5108 (setq link (concat 5370 (setq cpltxt (concat
5109 (if (org-xor arg org-usenet-links-prefer-google) 5371 (if (org-xor arg org-usenet-links-prefer-google)
5110 "http://groups.google.com/groups?group=" 5372 "http://groups.google.com/groups?group="
5111 "gnus:") 5373 "gnus:")
5112 group)))) 5374 group)
5375 link (org-make-link cpltxt))))
5113 5376
5114 ((memq major-mode '(gnus-summary-mode gnus-article-mode)) 5377 ((memq major-mode '(gnus-summary-mode gnus-article-mode))
5115 (and (eq major-mode 'gnus-article-mode) (gnus-article-show-summary)) 5378 (and (eq major-mode 'gnus-article-mode) (gnus-article-show-summary))
@@ -5128,27 +5391,34 @@ For file links, arg negates `org-line-numbers-in-file-links'."
5128 cpltxt "\n " 5391 cpltxt "\n "
5129 (format "http://groups.google.com/groups?as_umsgid=%s" 5392 (format "http://groups.google.com/groups?as_umsgid=%s"
5130 (org-fixup-message-id-for-http message-id)))) 5393 (org-fixup-message-id-for-http message-id))))
5131 (setq link (concat cpltxt "\n" "gnus:" group 5394 (setq link (concat cpltxt "\n"
5132 "#" (number-to-string article)))))) 5395 (org-make-link
5396 "gnus:" group
5397 "#" (number-to-string article)))))))
5133 5398
5134 ((eq major-mode 'w3-mode) 5399 ((eq major-mode 'w3-mode)
5135 (setq link (url-view-url t))) 5400 (setq cpltxt (url-view-url t)
5401 link (org-make-link cpltxt)))
5136 ((eq major-mode 'w3m-mode) 5402 ((eq major-mode 'w3m-mode)
5137 (setq link w3m-current-url)) 5403 (setq cpltxt w3m-current-url
5404 link (org-make-link cpltxt)))
5138 5405
5139 ((buffer-file-name) 5406 ((buffer-file-name)
5140 ;; Just link to this file here. 5407 ;; Just link to this file here.
5141 (setq link (concat "file:" 5408 (setq cpltxt (concat "file:"
5142 (abbreviate-file-name (buffer-file-name)))) 5409 (abbreviate-file-name (buffer-file-name))))
5143 ;; Add the line number? 5410 ;; Add the line number?
5144 (if (org-xor org-line-numbers-in-file-links arg) 5411 (if (org-xor org-line-numbers-in-file-links arg)
5145 (setq link 5412 (setq cpltxt
5146 (concat link 5413 (concat cpltxt
5147 ":" (int-to-string 5414 ":" (int-to-string
5148 (+ (if (bolp) 1 0) (count-lines 5415 (+ (if (bolp) 1 0) (count-lines
5149 (point-min) (point)))))))) 5416 (point-min) (point)))))))
5417 (setq link (org-make-link cpltxt)))
5418
5150 ((interactive-p) 5419 ((interactive-p)
5151 (error "Cannot link to a buffer which is not visiting a file")) 5420 (error "Cannot link to a buffer which is not visiting a file"))
5421
5152 (t (setq link nil))) 5422 (t (setq link nil)))
5153 5423
5154 (if (and (interactive-p) link) 5424 (if (and (interactive-p) link)
@@ -5158,6 +5428,10 @@ For file links, arg negates `org-line-numbers-in-file-links'."
5158 (message "Stored: %s" (or cpltxt link))) 5428 (message "Stored: %s" (or cpltxt link)))
5159 link))) 5429 link)))
5160 5430
5431(defun org-make-link (&rest strings)
5432 "Concatenate STRINGS, format resulting string with `org-link-format'."
5433 (format org-link-format (apply 'concat strings)))
5434
5161(defun org-xor (a b) 5435(defun org-xor (a b)
5162 "Exclusive or." 5436 "Exclusive or."
5163 (if a (not b) b)) 5437 (if a (not b) b))
@@ -5202,7 +5476,8 @@ For file links, arg negates `org-line-numbers-in-file-links'."
5202Completion can be used to select a link previously stored with 5476Completion can be used to select a link previously stored with
5203`org-store-link'. When the empty string is entered (i.e. if you just 5477`org-store-link'. When the empty string is entered (i.e. if you just
5204press RET at the prompt), the link defaults to the most recently 5478press RET at the prompt), the link defaults to the most recently
5205stored link. 5479stored link. As SPC triggers completion in the minibuffer, you need to
5480use M-SPC or C-q SPC to force the insertion of a space character.
5206 5481
5207With a \\[universal-argument] prefix, prompts for a file to link to. The file name can be 5482With a \\[universal-argument] prefix, prompts for a file to link to. The file name can be
5208selected using completion. The path to the file will be relative to 5483selected using completion. The path to the file will be relative to
@@ -5226,15 +5501,20 @@ is in the current directory or below."
5226 (let ((pwd (file-name-as-directory (expand-file-name ".")))) 5501 (let ((pwd (file-name-as-directory (expand-file-name "."))))
5227 (cond 5502 (cond
5228 ((equal complete-file '(16)) 5503 ((equal complete-file '(16))
5229 (insert "file:" (abbreviate-file-name (expand-file-name link)))) 5504 (insert
5505 (org-make-link
5506 "file:" (abbreviate-file-name (expand-file-name link)))))
5230 ((string-match (concat "^" (regexp-quote pwd) "\\(.+\\)") 5507 ((string-match (concat "^" (regexp-quote pwd) "\\(.+\\)")
5231 (expand-file-name link)) 5508 (expand-file-name link))
5232 (insert "file:" (match-string 1 (expand-file-name link)))) 5509 (insert
5233 (t (insert "file:" link)))) 5510 (org-make-link
5511 "file:" (match-string 1 (expand-file-name link)))))
5512 (t (insert (org-make-link "file:" link)))))
5234 (setq linktxt (cdr (assoc link org-stored-links))) 5513 (setq linktxt (cdr (assoc link org-stored-links)))
5235 (if (not org-keep-stored-link-after-insertion) 5514 (if (not org-keep-stored-link-after-insertion)
5236 (setq org-stored-links (delq (assoc link org-stored-links) 5515 (setq org-stored-links (delq (assoc link org-stored-links)
5237 org-stored-links))) 5516 org-stored-links)))
5517 (if (not linktxt) (setq link (org-make-link link)))
5238 (let ((lines (org-split-string (or linktxt link) "\n"))) 5518 (let ((lines (org-split-string (or linktxt link) "\n")))
5239 (insert (car lines)) 5519 (insert (car lines))
5240 (setq matched (string-match org-link-regexp (car lines))) 5520 (setq matched (string-match org-link-regexp (car lines)))
@@ -5301,7 +5581,7 @@ If the variable `org-adapt-indentation' is non-nil, the entire text is
5301also indented so that it starts in the same column as the headline 5581also indented so that it starts in the same column as the headline
5302\(i.e. after the stars). 5582\(i.e. after the stars).
5303 5583
5304See also the variable `org-reverse-note-order'." 5584See also the variable `org-reverse-note-order'."
5305 (catch 'quit 5585 (catch 'quit
5306 (let* ((txt (buffer-substring (point-min) (point-max))) 5586 (let* ((txt (buffer-substring (point-min) (point-max)))
5307 (fastp current-prefix-arg) 5587 (fastp current-prefix-arg)
@@ -5791,7 +6071,7 @@ If the field at the cursor is empty, copy into it the content of the nearest
5791non-empty field above. With argument N, use the Nth non-empty field. 6071non-empty field above. With argument N, use the Nth non-empty field.
5792If the current field is not empty, it is copied down to the next row, and 6072If the current field is not empty, it is copied down to the next row, and
5793the cursor is moved with it. Therefore, repeating this command causes the 6073the cursor is moved with it. Therefore, repeating this command causes the
5794column to be filled row-by-row. 6074column to be filled row-by-row.
5795If the variable `org-table-copy-increment' is non-nil and the field is an 6075If the variable `org-table-copy-increment' is non-nil and the field is an
5796integer, it will be incremented while copying." 6076integer, it will be incremented while copying."
5797 (interactive "p") 6077 (interactive "p")
@@ -5882,7 +6162,7 @@ When called interactively, column is also displayed in echo area."
5882(defun org-table-goto-column (n &optional on-delim force) 6162(defun org-table-goto-column (n &optional on-delim force)
5883 "Move the cursor to the Nth column in the current table line. 6163 "Move the cursor to the Nth column in the current table line.
5884With optional argument ON-DELIM, stop with point before the left delimiter 6164With optional argument ON-DELIM, stop with point before the left delimiter
5885of the field. 6165of the field.
5886If there are less than N fields, just go to after the last delimiter. 6166If there are less than N fields, just go to after the last delimiter.
5887However, when FORCE is non-nil, create new columns if necessary." 6167However, when FORCE is non-nil, create new columns if necessary."
5888 (let ((pos (point-at-eol))) 6168 (let ((pos (point-at-eol)))
@@ -5902,7 +6182,8 @@ However, when FORCE is non-nil, create new columns if necessary."
5902 (if (looking-at " ") (forward-char 1)))))) 6182 (if (looking-at " ") (forward-char 1))))))
5903 6183
5904(defun org-at-table-p (&optional table-type) 6184(defun org-at-table-p (&optional table-type)
5905 "Return t if the cursor is inside an org-type table." 6185 "Return t if the cursor is inside an org-type table.
6186If TABLE-TYPE is non-nil, also chack for table.el-type tables."
5906 (if org-enable-table-editor 6187 (if org-enable-table-editor
5907 (save-excursion 6188 (save-excursion
5908 (beginning-of-line 1) 6189 (beginning-of-line 1)
@@ -6082,7 +6363,7 @@ However, when FORCE is non-nil, create new columns if necessary."
6082 (if (not (org-at-table-p)) 6363 (if (not (org-at-table-p))
6083 (progn 6364 (progn
6084 (goto-char pos) 6365 (goto-char pos)
6085 (error "Cannot move row further."))) 6366 (error "Cannot move row further")))
6086 (goto-char pos) 6367 (goto-char pos)
6087 (beginning-of-line 1) 6368 (beginning-of-line 1)
6088 (setq pos (point)) 6369 (setq pos (point))
@@ -6169,7 +6450,7 @@ with `org-table-paste-rectangle'"
6169 (goto-char beg) 6450 (goto-char beg)
6170 (org-table-check-inside-data-field) 6451 (org-table-check-inside-data-field)
6171 (setq l01 (count-lines (point-min) (point)) 6452 (setq l01 (count-lines (point-min) (point))
6172 c01 (org-table-current-column)) 6453 c01 (org-table-current-column))
6173 (goto-char end) 6454 (goto-char end)
6174 (org-table-check-inside-data-field) 6455 (org-table-check-inside-data-field)
6175 (setq l02 (count-lines (point-min) (point)) 6456 (setq l02 (count-lines (point-min) (point))
@@ -6190,7 +6471,7 @@ with `org-table-paste-rectangle'"
6190 (setq l1 (1+ l1))))) 6471 (setq l1 (1+ l1)))))
6191 (setq org-table-clip (nreverse region)) 6472 (setq org-table-clip (nreverse region))
6192 (if cut (org-table-align)))) 6473 (if cut (org-table-align))))
6193 6474
6194(defun org-table-paste-rectangle () 6475(defun org-table-paste-rectangle ()
6195 "Paste a rectangular region into a table. 6476 "Paste a rectangular region into a table.
6196The upper right corner ends up in the current field. All involved fields 6477The upper right corner ends up in the current field. All involved fields
@@ -6301,7 +6582,7 @@ blank, and the content is appended to the field above."
6301 (+ (length org-table-clip) arg) 6582 (+ (length org-table-clip) arg)
6302 arg) 6583 arg)
6303 (length org-table-clip))) 6584 (length org-table-clip)))
6304 (setq org-table-clip 6585 (setq org-table-clip
6305 (mapcar 'list (org-wrap (mapconcat 'car org-table-clip " ") 6586 (mapcar 'list (org-wrap (mapconcat 'car org-table-clip " ")
6306 nil nlines))) 6587 nil nlines)))
6307 (goto-char beg) 6588 (goto-char beg)
@@ -6356,7 +6637,7 @@ The return value is a list of lines, without newlines at the end."
6356 (setq ll (org-do-wrap words w))) 6637 (setq ll (org-do-wrap words w)))
6357 ll)) 6638 ll))
6358 (t (error "Cannot wrap this"))))) 6639 (t (error "Cannot wrap this")))))
6359 6640
6360 6641
6361(defun org-do-wrap (words width) 6642(defun org-do-wrap (words width)
6362 "Create lines of maximum width WIDTH (in characters) from word list WORDS." 6643 "Create lines of maximum width WIDTH (in characters) from word list WORDS."
@@ -6681,28 +6962,32 @@ table editor in arbitrary modes.")
6681 6962
6682;;;###autoload 6963;;;###autoload
6683(defun orgtbl-mode (&optional arg) 6964(defun orgtbl-mode (&optional arg)
6684 "The `org-mode' table editor as a minor mode for use in other modes." 6965 "The `org-mode' table editor as a minor mode for use in other modes."
6685 (interactive) 6966 (interactive)
6686 (setq orgtbl-mode 6967 (if (eq major-mode 'org-mode)
6687 (if arg (> (prefix-numeric-value arg) 0) (not orgtbl-mode))) 6968 ;; Exit without error, in case some hook functions calls this
6688 (if orgtbl-mode 6969 ;; by accident in org-mode.
6689 (progn 6970 (message "Orgtbl-mode is not useful in org-mode, command ignored")
6690 (set (make-local-variable (quote org-table-may-need-update)) t) 6971 (setq orgtbl-mode
6691 (make-local-hook (quote before-change-functions)) 6972 (if arg (> (prefix-numeric-value arg) 0) (not orgtbl-mode)))
6692 (add-hook 'before-change-functions 'org-before-change-function 6973 (if orgtbl-mode
6693 nil 'local) 6974 (progn
6694 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp) 6975 (set (make-local-variable (quote org-table-may-need-update)) t)
6695 auto-fill-inhibit-regexp) 6976 (make-local-hook (quote before-change-functions))
6696 (set (make-local-variable 'auto-fill-inhibit-regexp) 6977 (add-hook 'before-change-functions 'org-before-change-function
6697 (if auto-fill-inhibit-regexp 6978 nil 'local)
6698 (concat "\\([ \t]*|\\|" auto-fill-inhibit-regexp) 6979 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp)
6699 "[ \t]*|")) 6980 auto-fill-inhibit-regexp)
6700 (easy-menu-add orgtbl-mode-menu) 6981 (set (make-local-variable 'auto-fill-inhibit-regexp)
6701 (run-hooks 'orgtbl-mode-hook)) 6982 (if auto-fill-inhibit-regexp
6702 (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp) 6983 (concat "\\([ \t]*|\\|" auto-fill-inhibit-regexp)
6703 (remove-hook 'before-change-functions 'org-before-change-function t) 6984 "[ \t]*|"))
6704 (easy-menu-remove orgtbl-mode-menu) 6985 (easy-menu-add orgtbl-mode-menu)
6705 (force-mode-line-update 'all))) 6986 (run-hooks 'orgtbl-mode-hook))
6987 (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp)
6988 (remove-hook 'before-change-functions 'org-before-change-function t)
6989 (easy-menu-remove orgtbl-mode-menu)
6990 (force-mode-line-update 'all))))
6706 6991
6707;; Install it as a minor mode. 6992;; Install it as a minor mode.
6708(put 'orgtbl-mode :included t) 6993(put 'orgtbl-mode :included t)
@@ -6711,7 +6996,9 @@ table editor in arbitrary modes.")
6711 6996
6712(defun orgtbl-make-binding (fun &rest keys) 6997(defun orgtbl-make-binding (fun &rest keys)
6713 "Create a function for binding in the table minor mode." 6998 "Create a function for binding in the table minor mode."
6714 (list 'lambda '(arg) '(interactive "p") 6999 (list 'lambda '(arg)
7000 (concat "Run `" (symbol-name fun) "' or the default binding.")
7001 '(interactive "p")
6715 (list 'if 7002 (list 'if
6716 '(org-at-table-p) 7003 '(org-at-table-p)
6717 (list 'call-interactively (list 'quote fun)) 7004 (list 'call-interactively (list 'quote fun))
@@ -6730,29 +7017,30 @@ table editor in arbitrary modes.")
6730 7017
6731;; Keybindings for the minor mode 7018;; Keybindings for the minor mode
6732(let ((bindings 7019(let ((bindings
6733 '(([(meta shift left)] org-table-delete-column) 7020 (list
6734 ([(meta left)] org-table-move-column-left) 7021 '([(meta shift left)] org-table-delete-column)
6735 ([(meta right)] org-table-move-column-right) 7022 '([(meta left)] org-table-move-column-left)
6736 ([(meta shift right)] org-table-insert-column) 7023 '([(meta right)] org-table-move-column-right)
6737 ([(meta shift up)] org-table-kill-row) 7024 '([(meta shift right)] org-table-insert-column)
6738 ([(meta shift down)] org-table-insert-row) 7025 '([(meta shift up)] org-table-kill-row)
6739 ([(meta up)] org-table-move-row-up) 7026 '([(meta shift down)] org-table-insert-row)
6740 ([(meta down)] org-table-move-row-down) 7027 '([(meta up)] org-table-move-row-up)
6741 ("\C-c\C-w" org-table-cut-region) 7028 '([(meta down)] org-table-move-row-down)
6742 ("\C-c\M-w" org-table-copy-region) 7029 '("\C-c\C-w" org-table-cut-region)
6743 ("\C-c\C-y" org-table-paste-rectangle) 7030 '("\C-c\M-w" org-table-copy-region)
6744 ("\C-c-" org-table-insert-hline) 7031 '("\C-c\C-y" org-table-paste-rectangle)
6745 ([(shift tab)] org-table-previous-field) 7032 '("\C-c-" org-table-insert-hline)
6746 ("\C-c\C-c" org-table-align) 7033 '([(shift tab)] org-table-previous-field)
6747 ([(return)] org-table-next-row) 7034 '("\C-c\C-c" org-table-align)
6748 ([(shift return)] org-table-copy-down) 7035 '("\C-m" org-table-next-row)
6749 ([(meta return)] org-table-wrap-region) 7036 (list (org-key 'S-return) 'org-table-copy-down)
6750 ("\C-c\C-q" org-table-wrap-region) 7037 '([(meta return)] org-table-wrap-region)
6751 ("\C-c?" org-table-current-column) 7038 '("\C-c\C-q" org-table-wrap-region)
6752 ("\C-c " org-table-blank-field) 7039 '("\C-c?" org-table-current-column)
6753 ("\C-c+" org-table-sum) 7040 '("\C-c " org-table-blank-field)
6754 ("\C-c|" org-table-toggle-vline-visibility) 7041 '("\C-c+" org-table-sum)
6755 ("\C-c=" org-table-eval-formula))) 7042 '("\C-c|" org-table-toggle-vline-visibility)
7043 '("\C-c=" org-table-eval-formula)))
6756 elt key fun cmd) 7044 elt key fun cmd)
6757 (while (setq elt (pop bindings)) 7045 (while (setq elt (pop bindings))
6758 (setq key (car elt) 7046 (setq key (car elt)
@@ -6761,20 +7049,12 @@ table editor in arbitrary modes.")
6761 (define-key orgtbl-mode-map key cmd))) 7049 (define-key orgtbl-mode-map key cmd)))
6762 7050
6763;; Special treatment needed for TAB and RET 7051;; Special treatment needed for TAB and RET
6764;(define-key orgtbl-mode-map [(return)] 7052
6765; (orgtbl-make-binding 'org-table-next-row [(return)] "\C-m")) 7053(define-key orgtbl-mode-map [(return)]
6766;(define-key orgtbl-mode-map "\C-m"
6767; (orgtbl-make-binding 'org-table-next-row "\C-m" [(return)]))
6768;(define-key orgtbl-mode-map [(tab)]
6769; (orgtbl-make-binding 'org-table-next-field [(tab)] "\C-i"))
6770;(define-key orgtbl-mode-map "\C-i"
6771; (orgtbl-make-binding 'org-table-next-field "\C-i" [(tab)]))
6772
6773(define-key orgtbl-mode-map [(return)]
6774 (orgtbl-make-binding 'orgtbl-ret [(return)] "\C-m")) 7054 (orgtbl-make-binding 'orgtbl-ret [(return)] "\C-m"))
6775(define-key orgtbl-mode-map "\C-m" 7055(define-key orgtbl-mode-map "\C-m"
6776 (orgtbl-make-binding 'orgtbl-ret "\C-m" [(return)])) 7056 (orgtbl-make-binding 'orgtbl-ret "\C-m" [(return)]))
6777(define-key orgtbl-mode-map [(tab)] 7057(define-key orgtbl-mode-map [(tab)]
6778 (orgtbl-make-binding 'orgtbl-tab [(tab)] "\C-i")) 7058 (orgtbl-make-binding 'orgtbl-tab [(tab)] "\C-i"))
6779(define-key orgtbl-mode-map "\C-i" 7059(define-key orgtbl-mode-map "\C-i"
6780 (orgtbl-make-binding 'orgtbl-tab "\C-i" [(tab)])) 7060 (orgtbl-make-binding 'orgtbl-tab "\C-i" [(tab)]))
@@ -6884,7 +7164,7 @@ a reduced column width."
6884 ["Fill Rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"]) 7164 ["Fill Rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"])
6885 "--" 7165 "--"
6886 ["Which Column?" org-table-current-column :active (org-at-table-p) :keys "C-c ?"] 7166 ["Which Column?" org-table-current-column :active (org-at-table-p) :keys "C-c ?"]
6887 ["Sum Column/Rectangle" org-table-sum 7167 ["Sum Column/Rectangle" org-table-sum
6888 :active (or (org-at-table-p) (org-region-active-p)) :keys "C-c +"] 7168 :active (or (org-at-table-p) (org-region-active-p)) :keys "C-c +"]
6889 ["Eval Formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="] 7169 ["Eval Formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="]
6890 )) 7170 ))
@@ -7396,9 +7676,10 @@ and all options lines."
7396 (let* ((filename (concat (file-name-sans-extension (buffer-file-name)) 7676 (let* ((filename (concat (file-name-sans-extension (buffer-file-name))
7397 ".txt")) 7677 ".txt"))
7398 (buffer (find-file-noselect filename)) 7678 (buffer (find-file-noselect filename))
7399 (ore (concat 7679 (ore (concat
7400 (org-make-options-regexp 7680 (org-make-options-regexp
7401 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP" 7681 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO"
7682 "STARTUP" "ARCHIVE"
7402 "TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")) 7683 "TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"))
7403 (if org-noutline-p "\\(\n\\|$\\)" ""))) 7684 (if org-noutline-p "\\(\n\\|$\\)" "")))
7404 s e) 7685 s e)
@@ -7453,6 +7734,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
7453#+SEQ_TODO: %s 7734#+SEQ_TODO: %s
7454#+TYP_TODO: %s 7735#+TYP_TODO: %s
7455#+STARTUP: %s %s 7736#+STARTUP: %s %s
7737#+ARCHIVE: %s
7456" 7738"
7457 (buffer-name) (user-full-name) user-mail-address org-export-default-language 7739 (buffer-name) (user-full-name) user-mail-address org-export-default-language
7458 org-export-headline-levels 7740 org-export-headline-levels
@@ -7475,6 +7757,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
7475 (cdr (assoc org-startup-folded 7757 (cdr (assoc org-startup-folded
7476 '((nil . "nofold")(t . "fold")(content . "content")))) 7758 '((nil . "nofold")(t . "fold")(content . "content"))))
7477 (if org-startup-with-deadline-check "dlcheck" "nodlcheck") 7759 (if org-startup-with-deadline-check "dlcheck" "nodlcheck")
7760 org-archive-location
7478 )) 7761 ))
7479 7762
7480(defun org-insert-export-options-template () 7763(defun org-insert-export-options-template ()
@@ -7571,6 +7854,7 @@ headlines. The default is 3. Lower levels will become bulleted lists."
7571 (text nil) 7854 (text nil)
7572 (lang-words nil) 7855 (lang-words nil)
7573 (head-count 0) cnt 7856 (head-count 0) cnt
7857 (start 0)
7574 table-open type 7858 table-open type
7575 table-buffer table-orig-buffer 7859 table-buffer table-orig-buffer
7576 ) 7860 )
@@ -7624,7 +7908,7 @@ headlines. The default is 3. Lower levels will become bulleted lists."
7624 ;; This is a headline 7908 ;; This is a headline
7625 (progn 7909 (progn
7626 (setq level (- (match-end 1) (match-beginning 1)) 7910 (setq level (- (match-end 1) (match-beginning 1))
7627 txt (save-match-data 7911 txt (save-match-data
7628 (org-html-expand 7912 (org-html-expand
7629 (match-string 3 line))) 7913 (match-string 3 line)))
7630 todo 7914 todo
@@ -7668,8 +7952,15 @@ headlines. The default is 3. Lower levels will become bulleted lists."
7668 )) 7952 ))
7669 (setq head-count 0) 7953 (setq head-count 0)
7670 (org-init-section-numbers) 7954 (org-init-section-numbers)
7671
7672 (while (setq line (pop lines) origline line) 7955 (while (setq line (pop lines) origline line)
7956 ;; Protect the links
7957 (setq start 0)
7958 (while (string-match org-link-maybe-angles-regexp line start)
7959 (setq start (match-end 0))
7960 (setq line (replace-match
7961 (concat "\000" (match-string 1 line) "\000")
7962 t t line)))
7963
7673 ;; replace "<" and ">" by "&lt;" and "&gt;" 7964 ;; replace "<" and ">" by "&lt;" and "&gt;"
7674 ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>") 7965 ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
7675 (setq line (org-html-expand line)) 7966 (setq line (org-html-expand line))
@@ -7687,27 +7978,34 @@ headlines. The default is 3. Lower levels will become bulleted lists."
7687 (not (string-match "^[ \t]+\\(:.*\\)" 7978 (not (string-match "^[ \t]+\\(:.*\\)"
7688 (car lines)))) 7979 (car lines))))
7689 "<br>\n" "\n")))) 7980 "<br>\n" "\n"))))
7690 7981 (setq start 0)
7691 (when (string-match org-link-regexp line) 7982 (while (string-match org-protected-link-regexp line start)
7983 (setq start (- (match-end 0) 2))
7692 (setq type (match-string 1 line)) 7984 (setq type (match-string 1 line))
7693 (cond 7985 (cond
7694 ((member type '("http" "https" "ftp" "mailto" "news")) 7986 ((member type '("http" "https" "ftp" "mailto" "news"))
7695 ;; standard URL 7987 ;; standard URL
7696 (setq line (replace-match 7988 (setq line (replace-match
7697 "<a href=\"\\1:\\2\">&lt;\\1:\\2&gt;</a>" 7989; "<a href=\"\\1:\\2\">&lt;\\1:\\2&gt;</a>"
7990 "<a href=\"\\1:\\2\">\\1:\\2</a>"
7698 nil nil line))) 7991 nil nil line)))
7699 ((string= type "file") 7992 ((string= type "file")
7700 ;; FILE link 7993 ;; FILE link
7701
7702 (let* ((filename (match-string 2 line)) 7994 (let* ((filename (match-string 2 line))
7995 (abs-p (file-name-absolute-p filename))
7996 (thefile (if abs-p (expand-file-name filename) filename))
7997 (thefile (save-match-data
7998 (if (string-match ":[0-9]+$" thefile)
7999 (replace-match "" t t thefile)
8000 thefile)))
7703 (file-is-image-p 8001 (file-is-image-p
7704 (save-match-data 8002 (save-match-data
7705 (string-match (org-image-file-name-regexp) filename)))) 8003 (string-match (org-image-file-name-regexp) thefile))))
7706 (setq line (replace-match 8004 (setq line (replace-match
7707 (if (and org-export-html-inline-images 8005 (if (and org-export-html-inline-images
7708 file-is-image-p) 8006 file-is-image-p)
7709 "<img src=\"\\2\"/>" 8007 (concat "<img src=\"" thefile "\"/>")
7710 "<a href=\"\\2\">\\1:\\2</a>") 8008 (concat "<a href=\"" thefile "\">\\1:\\2</a>"))
7711 nil nil line)))) 8009 nil nil line))))
7712 8010
7713 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell")) 8011 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell"))
@@ -7805,20 +8103,15 @@ headlines. The default is 3. Lower levels will become bulleted lists."
7805 (let ((head (and org-export-highlight-first-table-line 8103 (let ((head (and org-export-highlight-first-table-line
7806 (delq nil (mapcar 8104 (delq nil (mapcar
7807 (lambda (x) (string-match "^[ \t]*|-" x)) 8105 (lambda (x) (string-match "^[ \t]*|-" x))
7808 lines)))) 8106 (cdr lines)))))
7809 lastline line fields html empty) 8107 line fields html)
7810 (setq html (concat org-export-html-table-tag "\n")) 8108 (setq html (concat org-export-html-table-tag "\n"))
7811 (while (setq lastline line 8109 (while (setq line (pop lines))
7812 line (pop lines))
7813 (setq empty "&nbsp")
7814 (catch 'next-line 8110 (catch 'next-line
7815 (if (string-match "^[ \t]*|-" line) 8111 (if (string-match "^[ \t]*|-" line)
7816 (if lastline 8112 (progn
7817 ;; A hline: simulate an empty table row instead. 8113 (setq head nil) ;; head ends here, first time around
7818 (setq line (org-fake-empty-table-line lastline) 8114 ;; ignore this line
7819 head nil
7820 empty "")
7821 ;; Ignore this line
7822 (throw 'next-line t))) 8115 (throw 'next-line t)))
7823 ;; Break the line into fields 8116 ;; Break the line into fields
7824 (setq fields (org-split-string line "[ \t]*|[ \t]*")) 8117 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
@@ -7826,7 +8119,6 @@ headlines. The default is 3. Lower levels will become bulleted lists."
7826 html 8119 html
7827 "<tr>" 8120 "<tr>"
7828 (mapconcat (lambda (x) 8121 (mapconcat (lambda (x)
7829 (if (equal x "") (setq x empty))
7830 (if head 8122 (if head
7831 (concat "<th>" x "</th>") 8123 (concat "<th>" x "</th>")
7832 (concat "<td valign=\"top\">" x "</td>"))) 8124 (concat "<td valign=\"top\">" x "</td>")))
@@ -7899,7 +8191,7 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
7899 (insert (mapconcat 'identity lines "\n")) 8191 (insert (mapconcat 'identity lines "\n"))
7900 (goto-char (point-min)) 8192 (goto-char (point-min))
7901 (if (not (re-search-forward "|[^+]" nil t)) 8193 (if (not (re-search-forward "|[^+]" nil t))
7902 (error "Error processing table.")) 8194 (error "Error processing table"))
7903 (table-recognize-table) 8195 (table-recognize-table)
7904 (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer)) 8196 (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
7905 (table-generate-source 'html " org-tmp2 ") 8197 (table-generate-source 'html " org-tmp2 ")
@@ -7915,9 +8207,9 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
7915 (r (if m (substring string m) ""))) 8207 (r (if m (substring string m) "")))
7916 ;; convert < to &lt; and > to &gt; 8208 ;; convert < to &lt; and > to &gt;
7917 (while (string-match "<" s) 8209 (while (string-match "<" s)
7918 (setq s (replace-match "&lt;" nil nil s))) 8210 (setq s (replace-match "&lt;" t t s)))
7919 (while (string-match ">" s) 8211 (while (string-match ">" s)
7920 (setq s (replace-match "&gt;" nil nil s))) 8212 (setq s (replace-match "&gt;" t t s)))
7921 (if org-export-html-expand 8213 (if org-export-html-expand
7922 (while (string-match "@&lt;\\([^&]*\\)&gt;" s) 8214 (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
7923 (setq s (replace-match "<\\1>" nil nil s)))) 8215 (setq s (replace-match "<\\1>" nil nil s))))
@@ -8126,7 +8418,6 @@ When LEVEL is non-nil, increase section numbers on that level."
8126;; i k @ expendable from outline-mode 8418;; i k @ expendable from outline-mode
8127;; 0123456789 ! $%^& * ()_{} " ~`' free 8419;; 0123456789 ! $%^& * ()_{} " ~`' free
8128 8420
8129(define-key org-mode-map [(tab)] 'org-cycle)
8130(define-key org-mode-map "\C-i" 'org-cycle) 8421(define-key org-mode-map "\C-i" 'org-cycle)
8131(define-key org-mode-map [(meta tab)] 'org-complete) 8422(define-key org-mode-map [(meta tab)] 'org-complete)
8132(define-key org-mode-map "\M-\C-i" 'org-complete) 8423(define-key org-mode-map "\M-\C-i" 'org-complete)
@@ -8144,6 +8435,7 @@ When LEVEL is non-nil, increase section numbers on that level."
8144(define-key org-mode-map "\C-c\C-h\C-w" 'org-cut-special) 8435(define-key org-mode-map "\C-c\C-h\C-w" 'org-cut-special)
8145(define-key org-mode-map "\C-c\C-h\M-w" 'org-copy-special) 8436(define-key org-mode-map "\C-c\C-h\M-w" 'org-copy-special)
8146(define-key org-mode-map "\C-c\C-h\C-y" 'org-paste-special) 8437(define-key org-mode-map "\C-c\C-h\C-y" 'org-paste-special)
8438(define-key org-mode-map "\C-c$" 'org-archive-subtree)
8147(define-key org-mode-map "\C-c\C-j" 'org-goto) 8439(define-key org-mode-map "\C-c\C-j" 'org-goto)
8148(define-key org-mode-map "\C-c\C-t" 'org-todo) 8440(define-key org-mode-map "\C-c\C-t" 'org-todo)
8149(define-key org-mode-map "\C-c\C-s" 'org-schedule) 8441(define-key org-mode-map "\C-c\C-s" 'org-schedule)
@@ -8166,21 +8458,19 @@ When LEVEL is non-nil, increase section numbers on that level."
8166(define-key org-mode-map "\C-c[" 'org-add-file) 8458(define-key org-mode-map "\C-c[" 'org-add-file)
8167(define-key org-mode-map "\C-c]" 'org-remove-file) 8459(define-key org-mode-map "\C-c]" 'org-remove-file)
8168(define-key org-mode-map "\C-c\C-r" 'org-timeline) 8460(define-key org-mode-map "\C-c\C-r" 'org-timeline)
8169(define-key org-mode-map [(shift up)] 'org-shiftup) 8461(define-key org-mode-map (org-key 'S-up) 'org-shiftup)
8170(define-key org-mode-map [(shift down)] 'org-shiftdown) 8462(define-key org-mode-map (org-key 'S-down) 'org-shiftdown)
8171(define-key org-mode-map [(shift left)] 'org-timestamp-down-day) 8463(define-key org-mode-map (org-key 'S-left) 'org-timestamp-down-day)
8172(define-key org-mode-map [(shift right)] 'org-timestamp-up-day) 8464(define-key org-mode-map (org-key 'S-right) 'org-timestamp-up-day)
8173(define-key org-mode-map "\C-c-" 'org-table-insert-hline) 8465(define-key org-mode-map "\C-c-" 'org-table-insert-hline)
8174;; The following line is e.g. necessary for German keyboards under Suse Linux 8466;; The following line is e.g. necessary for German keyboards under Suse Linux
8175(unless org-xemacs-p 8467(unless org-xemacs-p
8176 (define-key org-mode-map [S-iso-lefttab] 'org-shifttab)) 8468 (define-key org-mode-map [S-iso-lefttab] 'org-shifttab))
8177(define-key org-mode-map [(shift tab)] 'org-shifttab) 8469(define-key org-mode-map [(shift tab)] 'org-shifttab)
8178(define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) 8470(define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c)
8179(define-key org-mode-map [(return)] 'org-return) 8471(define-key org-mode-map "\C-m" 'org-return)
8180(define-key org-mode-map [(shift return)] 'org-table-copy-down) 8472(define-key org-mode-map (org-key 'S-return) 'org-table-copy-down)
8181(define-key org-mode-map [(meta return)] 'org-meta-return) 8473(define-key org-mode-map [(meta return)] 'org-meta-return)
8182(define-key org-mode-map [(control up)] 'org-move-line-up)
8183(define-key org-mode-map [(control down)] 'org-move-line-down)
8184(define-key org-mode-map "\C-c?" 'org-table-current-column) 8474(define-key org-mode-map "\C-c?" 'org-table-current-column)
8185(define-key org-mode-map "\C-c " 'org-table-blank-field) 8475(define-key org-mode-map "\C-c " 'org-table-blank-field)
8186(define-key org-mode-map "\C-c+" 'org-table-sum) 8476(define-key org-mode-map "\C-c+" 'org-table-sum)
@@ -8199,15 +8489,12 @@ When LEVEL is non-nil, increase section numbers on that level."
8199(define-key org-mode-map "\C-c\C-xh" 'org-export-as-html) 8489(define-key org-mode-map "\C-c\C-xh" 'org-export-as-html)
8200(define-key org-mode-map "\C-c\C-x\C-h" 'org-export-as-html-and-open) 8490(define-key org-mode-map "\C-c\C-x\C-h" 'org-export-as-html-and-open)
8201 8491
8202
8203;; FIXME: Do we really need to save match data in these commands?
8204;; I would like to remove it in order to minimize impact.
8205;; Self-insert already does not preserve it. How much resources used by this???
8206
8207(defsubst org-table-p () 8492(defsubst org-table-p ()
8208 (if (and (eq major-mode 'org-mode) font-lock-mode) 8493 (if (and (eq major-mode 'org-mode) font-lock-mode)
8209 (eq (get-text-property (point) 'face) 'org-table-face) 8494 (eq (get-text-property (point) 'face) 'org-table)
8210 (save-match-data (org-at-table-p)))) 8495 ;; (save-match-data (org-at-table-p)))) ; FIXME: OK to not use this?
8496 (org-at-table-p)))
8497
8211 8498
8212(defun org-self-insert-command (N) 8499(defun org-self-insert-command (N)
8213 "Like `self-insert-command', use overwrite-mode for whitespace in tables. 8500 "Like `self-insert-command', use overwrite-mode for whitespace in tables.
@@ -8279,7 +8566,7 @@ a reduced column width."
8279 8566
8280(defun org-shiftcursor-error () 8567(defun org-shiftcursor-error ()
8281 "Throw an error because Shift-Cursor command was applied in wrong context." 8568 "Throw an error because Shift-Cursor command was applied in wrong context."
8282 (error "This command is only active in tables and on headlines.")) 8569 (error "This command is only active in tables and on headlines"))
8283 8570
8284(defun org-shifttab () 8571(defun org-shifttab ()
8285 "Call `(org-cycle t)' or `org-table-previous-field'." 8572 "Call `(org-cycle t)' or `org-table-previous-field'."
@@ -8410,7 +8697,7 @@ the automatic table editor has been turned off."
8410 (if (y-or-n-p "Convert inactive region to table? ") 8697 (if (y-or-n-p "Convert inactive region to table? ")
8411 (org-table-convert-region (region-beginning) (region-end) arg) 8698 (org-table-convert-region (region-beginning) (region-end) arg)
8412 (error "Abort"))) 8699 (error "Abort")))
8413 (t (error "No table at point, and no region to make one."))))) 8700 (t (error "No table at point, and no region to make one")))))
8414 8701
8415(defun org-return () 8702(defun org-return ()
8416 "Call `org-table-next-row' or `newline'." 8703 "Call `org-table-next-row' or `newline'."
@@ -8469,7 +8756,9 @@ the automatic table editor has been turned off."
8469 ["Promote Heading" org-metaleft (not (org-at-table-p))] 8756 ["Promote Heading" org-metaleft (not (org-at-table-p))]
8470 ["Promote Subtree" org-shiftmetaleft (not (org-at-table-p))] 8757 ["Promote Subtree" org-shiftmetaleft (not (org-at-table-p))]
8471 ["Demote Heading" org-metaright (not (org-at-table-p))] 8758 ["Demote Heading" org-metaright (not (org-at-table-p))]
8472 ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))]) 8759 ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))]
8760 "--"
8761 ["Archive Subtree" org-archive-subtree t])
8473 "--" 8762 "--"
8474 ("TODO Lists" 8763 ("TODO Lists"
8475 ["TODO/DONE/-" org-todo t] 8764 ["TODO/DONE/-" org-todo t]
@@ -8533,7 +8822,7 @@ the automatic table editor has been turned off."
8533 ["Fill Rectangle" org-table-wrap-region (org-at-table-p)]) 8822 ["Fill Rectangle" org-table-wrap-region (org-at-table-p)])
8534 "--" 8823 "--"
8535 ["Which Column?" org-table-current-column (org-at-table-p)] 8824 ["Which Column?" org-table-current-column (org-at-table-p)]
8536 ["Sum Column/Rectangle" org-table-sum 8825 ["Sum Column/Rectangle" org-table-sum
8537 (or (org-at-table-p) (org-region-active-p))] 8826 (or (org-at-table-p) (org-region-active-p))]
8538 ["Eval Formula" org-table-eval-formula (org-at-table-p)] 8827 ["Eval Formula" org-table-eval-formula (org-at-table-p)]
8539 "--" 8828 "--"
@@ -8576,10 +8865,10 @@ With optional NODE, go directly to that node."
8576 (Info-goto-node (format "(org)%s" (or node "")))) 8865 (Info-goto-node (format "(org)%s" (or node ""))))
8577 8866
8578(defun org-install-agenda-files-menu () 8867(defun org-install-agenda-files-menu ()
8579 (easy-menu-change 8868 (easy-menu-change
8580 '("Org") "File List for Agenda" 8869 '("Org") "File List for Agenda"
8581 (append 8870 (append
8582 (list 8871 (list
8583 ["Edit File List" (customize-variable 'org-agenda-files) t] 8872 ["Edit File List" (customize-variable 'org-agenda-files) t]
8584 ["Add Current File to List" org-add-file t] 8873 ["Add Current File to List" org-add-file t]
8585 ["Remove Current File from List" org-remove-file t] 8874 ["Remove Current File from List" org-remove-file t]
@@ -8694,7 +8983,7 @@ that can be added."
8694;; Functions needed for compatibility with old outline.el 8983;; Functions needed for compatibility with old outline.el
8695 8984
8696;; The following functions capture almost the entire compatibility code 8985;; The following functions capture almost the entire compatibility code
8697;; between the different versions of outline-mode. The only other place 8986;; between the different versions of outline-mode. The only other place
8698;; where this is important are the font-lock-keywords. Search for 8987;; where this is important are the font-lock-keywords. Search for
8699;; `org-noutline-p' to find it. 8988;; `org-noutline-p' to find it.
8700 8989
@@ -8734,11 +9023,11 @@ Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
8734 (outline-back-to-heading invisible-ok) 9023 (outline-back-to-heading invisible-ok)
8735 (if (looking-at outline-regexp) 9024 (if (looking-at outline-regexp)
8736 t 9025 t
8737 (if (re-search-backward (concat (if invisible-ok "[\r\n]" "^") 9026 (if (re-search-backward (concat (if invisible-ok "\\([\r\n]\\|^\\)" "^")
8738 outline-regexp) 9027 outline-regexp)
8739 nil t) 9028 nil t)
8740 (if invisible-ok 9029 (if invisible-ok
8741 (progn (forward-char 1) 9030 (progn (goto-char (match-end 1))
8742 (looking-at outline-regexp))) 9031 (looking-at outline-regexp)))
8743 (error "Before first heading"))))) 9032 (error "Before first heading")))))
8744 9033
@@ -8759,7 +9048,7 @@ If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
8759This function considers both visible and invisible heading lines. 9048This function considers both visible and invisible heading lines.
8760With argument, move up ARG levels." 9049With argument, move up ARG levels."
8761 (if org-noutline-p 9050 (if org-noutline-p
8762 (if (fboundp 'outline-up-heading-all) 9051 (if (fboundp 'outline-up-heading-all)
8763 (outline-up-heading-all arg) ; emacs 21 version of outline.el 9052 (outline-up-heading-all arg) ; emacs 21 version of outline.el
8764 (outline-up-heading arg t)) ; emacs 22 version of outline.el 9053 (outline-up-heading arg t)) ; emacs 22 version of outline.el
8765 (org-back-to-heading t) 9054 (org-back-to-heading t)
@@ -8815,8 +9104,8 @@ When ENTRY is non-nil, show the entire entry."
8815 9104
8816(defun org-show-subtree () 9105(defun org-show-subtree ()
8817 "Show everything after this heading at deeper levels." 9106 "Show everything after this heading at deeper levels."
8818 (outline-flag-region 9107 (outline-flag-region
8819 (point) 9108 (point)
8820 (save-excursion 9109 (save-excursion
8821 (outline-end-of-subtree) (outline-next-heading) (point)) 9110 (outline-end-of-subtree) (outline-next-heading) (point))
8822 (if org-noutline-p nil ?\n))) 9111 (if org-noutline-p nil ?\n)))
@@ -8827,7 +9116,7 @@ Show the heading too, if it is currently invisible."
8827 (interactive) 9116 (interactive)
8828 (save-excursion 9117 (save-excursion
8829 (org-back-to-heading t) 9118 (org-back-to-heading t)
8830 (outline-flag-region 9119 (outline-flag-region
8831 (1- (point)) 9120 (1- (point))
8832 (save-excursion 9121 (save-excursion
8833 (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move) 9122 (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move)
@@ -8860,6 +9149,4 @@ Show the heading too, if it is currently invisible."
8860(run-hooks 'org-load-hook) 9149(run-hooks 'org-load-hook)
8861 9150
8862;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd 9151;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
8863
8864;;; org.el ends here 9152;;; org.el ends here
8865