aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik2007-08-30 09:49:14 +0000
committerCarsten Dominik2007-08-30 09:49:14 +0000
commit374585c99c01e496251798d2d6aeeb7d8eeddcb2 (patch)
tree964f559346e1f8b475ec05ca45b0f8466f460312
parentff95e2465d62dea739c3f32ed3a3c62e8b567ef5 (diff)
downloademacs-374585c99c01e496251798d2d6aeeb7d8eeddcb2.tar.gz
emacs-374585c99c01e496251798d2d6aeeb7d8eeddcb2.zip
(org-export-visible): Fix drawers before export.
(org-do-sort): Allow sorting by priority. (org-agenda-files): Ignore non-existing files. (org-agenda-skip-unavailable-files): New variable. (org-ellipsis): All a face as value. (org-mode): Interprete the face value of `org-ellipsis'. (org-archive-save-context-info): New option. (org-archive-subtree): Store context info in archived entry. (org-fast-tag-selection-can-set-todo-state): New variable. (org-fast-tag-selection): Allow setting TODO states through this interface. (org-cycle): Docstring updated. (org-todo-keyword-faces): New option. (org-get-todo-face): New function. (org-set-font-lock-defaults, org-agenda-highlight-todo): Use `org-get-todo-face'. (org-switch-to-buffer-other-window): New function. (org-table-edit-field, org-table-show-reference) (org-table-edit-formulas, org-add-log-note) (org-fast-tag-selection, org-agenda, org-prepare-agenda) (org-timeline): Use `org-switch-to-buffer-other-window' instead of `switch-to-buffer-other-window' to make sure that the temporary windows show up on the current frame. (org-mhe-get-message-real-folder, org-batch-store-agenda-views) (org-get-entries-from-diary, org-replace-region-by-html): Don't allow pop-up frames. (org-agenda-get-deadlines, org-agenda-get-scheduled): Fixed problems with time-of-day. (org-export-get-title-from-subtree): New function. (org-agenda-get-scheduled, org-agenda-get-deadlines): Fix problems with listing items that are DONE. (org-change-tag-in-region): New command. (org-agenda-skip-scheduled-if-done) (org-agenda-skip-deadline-if-done): Docstring clarified. (org-mode): Hide drawers on startup. (org-get-todo-face): New function. (org-todo-keyword-faces): New option.
-rw-r--r--lisp/textmodes/org.el720
-rw-r--r--man/ChangeLog4
2 files changed, 515 insertions, 209 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index e6f289a4a6d..98874754664 100644
--- a/lisp/textmodes/org.el
+++ b/lisp/textmodes/org.el
@@ -5,7 +5,7 @@
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, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ 7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
8;; Version: 5.05 8;; Version: 5.07
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -83,7 +83,7 @@
83 83
84;;; Version 84;;; Version
85 85
86(defconst org-version "5.05" 86(defconst org-version "5.07"
87 "The version number of the file org.el.") 87 "The version number of the file org.el.")
88(defun org-version () 88(defun org-version ()
89 (interactive) 89 (interactive)
@@ -236,11 +236,13 @@ Or return the original if not disputed."
236(defcustom org-ellipsis nil 236(defcustom org-ellipsis nil
237 "The ellipsis to use in the Org-mode outline. 237 "The ellipsis to use in the Org-mode outline.
238When nil, just use the standard three dots. When a string, use that instead, 238When nil, just use the standard three dots. When a string, use that instead,
239and just in Org-mode (which will then use its own display table). 239When a face, use the standart 3 dots, but with the specified face.
240The change affects only Org-mode (which will then use its own display table).
240Changing this requires executing `M-x org-mode' in a buffer to become 241Changing this requires executing `M-x org-mode' in a buffer to become
241effective." 242effective."
242 :group 'org-startup 243 :group 'org-startup
243 :type '(choice (const :tag "Default" nil) 244 :type '(choice (const :tag "Default" nil)
245 (face :tag "Face" :value org-warning)
244 (string :tag "String" :value "...#"))) 246 (string :tag "String" :value "...#")))
245 247
246(defvar org-display-table nil 248(defvar org-display-table nil
@@ -274,11 +276,6 @@ Changes become only effective after restarting Emacs."
274 :group 'org-keywords 276 :group 'org-keywords
275 :type 'string) 277 :type 'string)
276 278
277(defcustom org-archived-string "ARCHIVED:"
278 "String used as the prefix for timestamps logging archiving a TODO entry."
279 :group 'org-keywords
280 :type 'string)
281
282(defcustom org-clock-string "CLOCK:" 279(defcustom org-clock-string "CLOCK:"
283 "String used as prefix for timestamps clocking work hours on an item." 280 "String used as prefix for timestamps clocking work hours on an item."
284 :group 'org-keywords 281 :group 'org-keywords
@@ -428,7 +425,7 @@ the property API."
428 :group 'org-structure 425 :group 'org-structure
429 :type '(repeat (string :tag "Drawer Name"))) 426 :type '(repeat (string :tag "Drawer Name")))
430 427
431(defcustom org-cycle-global-at-bob t 428(defcustom org-cycle-global-at-bob nil
432 "Cycle globally if cursor is at beginning of buffer and not at a headline. 429 "Cycle globally if cursor is at beginning of buffer and not at a headline.
433This makes it possible to do global cycling without having to use S-TAB or 430This makes it possible to do global cycling without having to use S-TAB or
434C-u TAB. For this special case to work, the first line of the buffer 431C-u TAB. For this special case to work, the first line of the buffer
@@ -489,19 +486,24 @@ the values `folded', `children', or `subtree'."
489 :tag "Org Edit Structure" 486 :tag "Org Edit Structure"
490 :group 'org-structure) 487 :group 'org-structure)
491 488
492
493(defcustom org-special-ctrl-a/e nil 489(defcustom org-special-ctrl-a/e nil
494 "Non-nil means `C-a' and `C-e' behave specially in headlines and items. 490 "Non-nil means `C-a' and `C-e' behave specially in headlines and items.
495When set, `C-a' will bring back the cursor to the beginning of the 491When t, `C-a' will bring back the cursor to the beginning of the
496headline text, i.e. after the stars and after a possible TODO keyword. 492headline text, i.e. after the stars and after a possible TODO keyword.
497In an item, this will be the position after the bullet. 493In an item, this will be the position after the bullet.
498When the cursor is already at that position, another `C-a' will bring 494When the cursor is already at that position, another `C-a' will bring
499it to the beginning of the line. 495it to the beginning of the line.
500`C-e' will jump to the end of the headline, ignoring the presence of tags 496`C-e' will jump to the end of the headline, ignoring the presence of tags
501in the headline. A second `C-e' will then jump to the true end of the 497in the headline. A second `C-e' will then jump to the true end of the
502line, after any tags." 498line, after any tags.
499When set to the symbol `reversed', the first `C-a' or `C-e' works normally,
500and only a directly following, identical keypress will bring the cursor
501to the special positions."
503 :group 'org-edit-structure 502 :group 'org-edit-structure
504 :type 'boolean) 503 :type '(choice
504 (const :tag "off" nil)
505 (const :tag "after bullet first" t)
506 (const :tag "border first" reversed)))
505 507
506(if (fboundp 'defvaralias) 508(if (fboundp 'defvaralias)
507 (defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e)) 509 (defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e))
@@ -714,6 +716,32 @@ use the first keyword in its list that means done."
714 :group 'org-archive 716 :group 'org-archive
715 :type 'boolean) 717 :type 'boolean)
716 718
719(defcustom org-archive-save-context-info '(time file category todo itags)
720 "Parts of context info that should be stored as properties when archiving.
721When a subtree is moved to an archive file, it looses information given by
722context, like inherited tags, the category, and possibly also the TODO
723state (depending on the variable `org-archive-mark-done').
724This variable can be a list of any of the following symbols:
725
726time The time of archiving.
727file The file where the entry originates.
728itags The local tags, in the headline of the subtree.
729ltags The tags the subtree inherits from further up the hierarchy.
730todo The pre-archive TODO state.
731category The category, taken from file name or #+CATEGORY lines.
732
733For each symbol present in the list, a property will be created in
734the archived entry, with a prefix \"PRE_ARCHIVE_\", to remember this
735information."
736 :group 'org-archive
737 :type '(set
738 (const :tag "File" file)
739 (const :tag "Category" category)
740 (const :tag "TODO state" todo)
741 (const :tag "TODO state" priority)
742 (const :tag "Inherited tags" itags)
743 (const :tag "Local tags" ltags)))
744
717(defgroup org-table nil 745(defgroup org-table nil
718 "Options concerning tables in Org-mode." 746 "Options concerning tables in Org-mode."
719 :tag "Org Table" 747 :tag "Org Table"
@@ -1480,6 +1508,8 @@ taken from the (otherwise obsolete) variable `org-todo-interpretation'."
1480 1508
1481(defvar org-todo-keywords-1 nil) 1509(defvar org-todo-keywords-1 nil)
1482(make-variable-buffer-local 'org-todo-keywords-1) 1510(make-variable-buffer-local 'org-todo-keywords-1)
1511(defvar org-todo-tag-alist nil)
1512(make-variable-buffer-local 'org-todo-tag-alist)
1483(defvar org-todo-keywords-for-agenda nil) 1513(defvar org-todo-keywords-for-agenda nil)
1484(defvar org-done-keywords-for-agenda nil) 1514(defvar org-done-keywords-for-agenda nil)
1485(defvar org-not-done-keywords nil) 1515(defvar org-not-done-keywords nil)
@@ -1863,6 +1893,11 @@ agenda file per line."
1863 (repeat :tag "List of files" file) 1893 (repeat :tag "List of files" file)
1864 (file :tag "Store list in a file\n" :value "~/.agenda_files"))) 1894 (file :tag "Store list in a file\n" :value "~/.agenda_files")))
1865 1895
1896(defcustom org-agenda-skip-unavailable-files nil
1897 "t means to just skip non-reachable files in `org-agenda-files'.
1898Nil means to remove them, after a query, from the list."
1899 :group 'org-agenda
1900 :type 'boolean)
1866 1901
1867(defcustom org-agenda-confirm-kill 1 1902(defcustom org-agenda-confirm-kill 1
1868 "When set, remote killing from the agenda buffer needs confirmation. 1903 "When set, remote killing from the agenda buffer needs confirmation.
@@ -2111,15 +2146,19 @@ The idea behind this is that such items will appear in the agenda anyway."
2111 2146
2112(defcustom org-agenda-skip-scheduled-if-done nil 2147(defcustom org-agenda-skip-scheduled-if-done nil
2113 "Non-nil means don't show scheduled items in agenda when they are done. 2148 "Non-nil means don't show scheduled items in agenda when they are done.
2114This is relevant for the daily/weekly agenda, not for the TODO list." 2149This is relevant for the daily/weekly agenda, not for the TODO list. And
2150it applied only to the actualy date of the scheduling. Warnings about
2151an item with a past scheduling dates are always turned off when the item
2152is DONE."
2115 :group 'org-agenda-skip 2153 :group 'org-agenda-skip
2116 :type 'boolean) 2154 :type 'boolean)
2117 2155
2118(defcustom org-agenda-skip-deadline-if-done nil 2156(defcustom org-agenda-skip-deadline-if-done nil
2119 "Non-nil means don't show deadines when the corresponding item is done. 2157 "Non-nil means don't show deadines when the corresponding item is done.
2120When nil, the deadline is still shown and should give you a happy feeling. 2158When nil, the deadline is still shown and should give you a happy feeling.
2121 2159This is relevant for the daily/weekly agenda. And it applied only to the
2122This is relevant for the daily/weekly agenda." 2160actualy date of the deadline. Warnings about approching and past-due
2161deadlines are always turned off when the item is DONE."
2123 :group 'org-agenda-skip 2162 :group 'org-agenda-skip
2124 :type 'boolean) 2163 :type 'boolean)
2125 2164
@@ -2544,16 +2583,17 @@ This is a property list with the following properties:
2544This path may be relative to the directory where the Org-mode file lives. 2583This path may be relative to the directory where the Org-mode file lives.
2545The default is to put them into the same directory as the Org-mode file. 2584The default is to put them into the same directory as the Org-mode file.
2546The variable may also be an alist with export types `:html', `:ascii', 2585The variable may also be an alist with export types `:html', `:ascii',
2547`:ical', or `:xoxo' and the corresponding directories. If a directory path 2586`:ical', `:LaTeX', or `:xoxo' and the corresponding directories.
2548is relative, it is interpreted relative to the directory where the exported 2587If a directory path is relative, it is interpreted relative to the
2549Org-mode files lives." 2588directory where the exported Org-mode files lives."
2550 :group 'org-export-general 2589 :group 'org-export-general
2551 :type '(choice 2590 :type '(choice
2552 (directory) 2591 (directory)
2553 (repeat 2592 (repeat
2554 (cons 2593 (cons
2555 (choice :tag "Type" 2594 (choice :tag "Type"
2556 (const :html) (const :ascii) (const :ical) (const :xoxo)) 2595 (const :html) (const :LaTeX)
2596 (const :ascii) (const :ical) (const :xoxo))
2557 (directory))))) 2597 (directory)))))
2558 2598
2559(defcustom org-export-language-setup 2599(defcustom org-export-language-setup
@@ -3157,7 +3197,7 @@ Use customize to modify this, or restart Emacs after changing it."
3157 '(("*" bold "<b>" "</b>") 3197 '(("*" bold "<b>" "</b>")
3158 ("/" italic "<i>" "</i>") 3198 ("/" italic "<i>" "</i>")
3159 ("_" underline "<u>" "</u>") 3199 ("_" underline "<u>" "</u>")
3160 ("=" shadow "<code>" "</code>") 3200 ("=" org-code "<code>" "</code>")
3161 ("+" (:strike-through t) "<del>" "</del>") 3201 ("+" (:strike-through t) "<del>" "</del>")
3162 ) 3202 )
3163"Special syntax for emphasized text. 3203"Special syntax for emphasized text.
@@ -3418,6 +3458,18 @@ This face is only used if `org-fontify-done-headline' is set. If applies
3418to the part of the headline after the DONE keyword." 3458to the part of the headline after the DONE keyword."
3419 :group 'org-faces) 3459 :group 'org-faces)
3420 3460
3461(defcustom org-todo-keyword-faces nil
3462 "Faces for specific TODO keywords.
3463This is a list of cons cells, with TODO keywords in the car
3464and faces in the cdr. The face can be a symbol, or a property
3465list of attributes, like (:foreground \"blue\" :weight bold :underline t)."
3466 :group 'org-faces
3467 :group 'org-todo
3468 :type '(repeat
3469 (cons
3470 (string :tag "keyword")
3471 (sexp :tag "face"))))
3472
3421(defface org-table ;; font-lock-function-name-face 3473(defface org-table ;; font-lock-function-name-face
3422 (org-compatible-face 3474 (org-compatible-face
3423 '((((class color) (min-colors 88) (background light)) (:foreground "Blue1")) 3475 '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
@@ -3439,6 +3491,20 @@ to the part of the headline after the DONE keyword."
3439 "Face for formulas." 3491 "Face for formulas."
3440 :group 'org-faces) 3492 :group 'org-faces)
3441 3493
3494(defface org-code
3495 (org-compatible-face
3496 '((((class color grayscale) (min-colors 88) (background light))
3497 (:foreground "grey50"))
3498 (((class color grayscale) (min-colors 88) (background dark))
3499 (:foreground "grey70"))
3500 (((class color) (min-colors 8) (background light))
3501 (:foreground "green"))
3502 (((class color) (min-colors 8) (background dark))
3503 (:foreground "yellow"))))
3504 "Face for fixed-with text like code snippets."
3505 :group 'org-faces
3506 :version "22.1")
3507
3442(defface org-agenda-structure ;; font-lock-function-name-face 3508(defface org-agenda-structure ;; font-lock-function-name-face
3443 (org-compatible-face 3509 (org-compatible-face
3444 '((((class color) (min-colors 88) (background light)) (:foreground "Blue1")) 3510 '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
@@ -3665,6 +3731,7 @@ means to push this value onto the list in the variable.")
3665 (when (org-mode-p) 3731 (when (org-mode-p)
3666 (org-set-local 'org-todo-kwd-alist nil) 3732 (org-set-local 'org-todo-kwd-alist nil)
3667 (org-set-local 'org-todo-keywords-1 nil) 3733 (org-set-local 'org-todo-keywords-1 nil)
3734 (org-set-local 'org-todo-tag-alist nil)
3668 (org-set-local 'org-done-keywords nil) 3735 (org-set-local 'org-done-keywords nil)
3669 (org-set-local 'org-todo-heads nil) 3736 (org-set-local 'org-todo-heads nil)
3670 (org-set-local 'org-todo-sets nil) 3737 (org-set-local 'org-todo-sets nil)
@@ -3673,8 +3740,8 @@ means to push this value onto the list in the variable.")
3673 "STARTUP" "ARCHIVE" "TAGS" "LINK" "PRIORITIES" 3740 "STARTUP" "ARCHIVE" "TAGS" "LINK" "PRIORITIES"
3674 "CONSTANTS" "PROPERTY"))) 3741 "CONSTANTS" "PROPERTY")))
3675 (splitre "[ \t]+") 3742 (splitre "[ \t]+")
3676 kwds key value cat arch tags const links hw dws tail sep kws1 prio 3743 kwds kws0 kwsa key value cat arch tags const links hw dws
3677 props) 3744 tail sep kws1 prio props)
3678 (save-excursion 3745 (save-excursion
3679 (save-restriction 3746 (save-restriction
3680 (widen) 3747 (widen)
@@ -3747,13 +3814,25 @@ means to push this value onto the list in the variable.")
3747 (let (inter kws) 3814 (let (inter kws)
3748 (while (setq kws (pop kwds)) 3815 (while (setq kws (pop kwds))
3749 (setq inter (pop kws) sep (member "|" kws) 3816 (setq inter (pop kws) sep (member "|" kws)
3750 kws1 (delete "|" (copy-sequence kws)) 3817 kws0 (delete "|" (copy-sequence kws))
3818 kwsa nil
3819 kws1 (mapcar (lambda (x)
3820 (if (string-match "\\(.*\\)(\\(.\\))" x)
3821 (progn
3822 (push (cons (match-string 1 x)
3823 (string-to-char
3824 (match-string 2 x))) kwsa)
3825 (match-string 1 x))
3826 x))
3827 kws0)
3828 kwsa (if kwsa (append '((:startgroup)) kwsa '((:endgroup))))
3751 hw (car kws1) 3829 hw (car kws1)
3752 dws (if sep (cdr sep) (last kws1)) 3830 dws (if sep (cdr sep) (last kws1))
3753 tail (list inter hw (car dws) (org-last dws))) 3831 tail (list inter hw (car dws) (org-last dws)))
3754 (add-to-list 'org-todo-heads hw 'append) 3832 (add-to-list 'org-todo-heads hw 'append)
3755 (push kws1 org-todo-sets) 3833 (push kws1 org-todo-sets)
3756 (setq org-done-keywords (append org-done-keywords dws nil)) 3834 (setq org-done-keywords (append org-done-keywords dws nil))
3835 (setq org-todo-tag-alist (append org-todo-tag-alist kwsa))
3757 (mapc (lambda (x) (push (cons x tail) org-todo-kwd-alist)) kws1) 3836 (mapc (lambda (x) (push (cons x tail) org-todo-kwd-alist)) kws1)
3758 (setq org-todo-keywords-1 (append org-todo-keywords-1 kws1 nil))) 3837 (setq org-todo-keywords-1 (append org-todo-keywords-1 kws1 nil)))
3759 (setq org-todo-sets (nreverse org-todo-sets) 3838 (setq org-todo-sets (nreverse org-todo-sets)
@@ -3834,28 +3913,25 @@ means to push this value onto the list in the variable.")
3834 (concat "\\<\\(" org-scheduled-string 3913 (concat "\\<\\(" org-scheduled-string
3835 "\\|" org-deadline-string 3914 "\\|" org-deadline-string
3836 "\\|" org-closed-string 3915 "\\|" org-closed-string
3837 "\\|" org-archived-string
3838 "\\|" org-clock-string "\\)" 3916 "\\|" org-clock-string "\\)"
3839 " *[[<]\\([^]>]+\\)[]>]") 3917 " *[[<]\\([^]>]+\\)[]>]")
3840 org-keyword-time-not-clock-regexp 3918 org-keyword-time-not-clock-regexp
3841 (concat "\\<\\(" org-scheduled-string 3919 (concat "\\<\\(" org-scheduled-string
3842 "\\|" org-deadline-string 3920 "\\|" org-deadline-string
3843 "\\|" org-closed-string 3921 "\\|" org-closed-string
3844 "\\|" org-archived-string
3845 "\\)" 3922 "\\)"
3846 " *[[<]\\([^]>]+\\)[]>]") 3923 " *[[<]\\([^]>]+\\)[]>]")
3847 org-maybe-keyword-time-regexp 3924 org-maybe-keyword-time-regexp
3848 (concat "\\(\\<\\(" org-scheduled-string 3925 (concat "\\(\\<\\(" org-scheduled-string
3849 "\\|" org-deadline-string 3926 "\\|" org-deadline-string
3850 "\\|" org-closed-string 3927 "\\|" org-closed-string
3851 "\\|" org-archived-string
3852 "\\|" org-clock-string "\\)\\)?" 3928 "\\|" org-clock-string "\\)\\)?"
3853 " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)") 3929 " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
3854 org-planning-or-clock-line-re 3930 org-planning-or-clock-line-re
3855 (concat "\\(?:^[ \t]*\\(" org-scheduled-string 3931 (concat "\\(?:^[ \t]*\\(" org-scheduled-string
3856 "\\|" org-deadline-string 3932 "\\|" org-deadline-string
3857 "\\|" org-closed-string "\\|" org-clock-string 3933 "\\|" org-closed-string "\\|" org-clock-string
3858 "\\|" org-archived-string "\\)\\>\\)") 3934 "\\)\\>\\)")
3859 ) 3935 )
3860 3936
3861 (org-set-font-lock-defaults))) 3937 (org-set-font-lock-defaults)))
@@ -3922,6 +3998,7 @@ This is for getting out of special buffers like remember.")
3922 3998
3923;; Defined somewhere in this file, but used before definition. 3999;; Defined somewhere in this file, but used before definition.
3924(defvar orgtbl-mode-menu) ; defined when orgtbl mode get initialized 4000(defvar orgtbl-mode-menu) ; defined when orgtbl mode get initialized
4001(defvar org-agenda-buffer-name)
3925(defvar org-agenda-undo-list) 4002(defvar org-agenda-undo-list)
3926(defvar org-agenda-pending-undo-list) 4003(defvar org-agenda-pending-undo-list)
3927(defvar org-agenda-overriding-header) 4004(defvar org-agenda-overriding-header)
@@ -4109,12 +4186,17 @@ The following commands are available:
4109 (org-set-local 'line-move-ignore-invisible t)) 4186 (org-set-local 'line-move-ignore-invisible t))
4110 (org-set-local 'outline-regexp "\\*+ ") 4187 (org-set-local 'outline-regexp "\\*+ ")
4111 (setq outline-level 'org-outline-level) 4188 (setq outline-level 'org-outline-level)
4112 (when (and org-ellipsis (stringp org-ellipsis) 4189 (when (and org-ellipsis
4113 (fboundp 'set-display-table-slot) (boundp 'buffer-display-table)) 4190 (fboundp 'set-display-table-slot) (boundp 'buffer-display-table)
4191 (fboundp 'make-glyph-code))
4114 (unless org-display-table 4192 (unless org-display-table
4115 (setq org-display-table (make-display-table))) 4193 (setq org-display-table (make-display-table)))
4116 (set-display-table-slot org-display-table 4194 (set-display-table-slot
4117 4 (string-to-vector org-ellipsis)) 4195 org-display-table 4
4196 (vconcat (mapcar
4197 (lambda (c) (make-glyph-code c (and (not (stringp org-ellipsis))
4198 org-ellipsis)))
4199 (if (stringp org-ellipsis) org-ellipsis "..."))))
4118 (setq buffer-display-table org-display-table)) 4200 (setq buffer-display-table org-display-table))
4119 (org-set-regexps-and-options) 4201 (org-set-regexps-and-options)
4120 ;; Calc embedded 4202 ;; Calc embedded
@@ -4159,6 +4241,7 @@ The following commands are available:
4159 (let ((bmp (buffer-modified-p))) 4241 (let ((bmp (buffer-modified-p)))
4160 (org-table-map-tables 'org-table-align) 4242 (org-table-map-tables 'org-table-align)
4161 (set-buffer-modified-p bmp))) 4243 (set-buffer-modified-p bmp)))
4244 (org-cycle-hide-drawers 'all)
4162 (cond 4245 (cond
4163 ((eq org-startup-folded t) 4246 ((eq org-startup-folded t)
4164 (org-cycle '(4))) 4247 (org-cycle '(4)))
@@ -4560,10 +4643,11 @@ between words."
4560 (let* ((em org-fontify-emphasized-text) 4643 (let* ((em org-fontify-emphasized-text)
4561 (lk org-activate-links) 4644 (lk org-activate-links)
4562 (org-font-lock-extra-keywords 4645 (org-font-lock-extra-keywords
4563 ;; Headlines
4564 (list 4646 (list
4647 ;; Headlines
4565 '("^\\(\\**\\)\\(\\* \\)\\(.*\\)" (1 (org-get-level-face 1)) 4648 '("^\\(\\**\\)\\(\\* \\)\\(.*\\)" (1 (org-get-level-face 1))
4566 (2 (org-get-level-face 2)) (3 (org-get-level-face 3))) 4649 (2 (org-get-level-face 2)) (3 (org-get-level-face 3)))
4650 ;; Table lines
4567 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" 4651 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
4568 (1 'org-table)) 4652 (1 'org-table))
4569 ;; Links 4653 ;; Links
@@ -4576,15 +4660,21 @@ between words."
4576 '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t)) 4660 '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
4577 '(org-hide-wide-columns (0 nil append)) 4661 '(org-hide-wide-columns (0 nil append))
4578 ;; TODO lines 4662 ;; TODO lines
4579 (list (concat "^\\*+[ \t]+" org-not-done-regexp) 4663 (list (concat "^\\*+[ \t]+" org-todo-regexp)
4580 '(1 'org-todo t)) 4664 '(1 (org-get-todo-face 1) t))
4665 ;; DONE
4666 (if org-fontify-done-headline
4667 (list (concat "^[*]+ +\\<\\("
4668 (mapconcat 'regexp-quote org-done-keywords "\\|")
4669 "\\)\\(.*\\)")
4670 '(2 'org-headline-done t))
4671 nil)
4581 ;; Priorities 4672 ;; Priorities
4582 (list (concat "\\[#[A-Z0-9]\\]") '(0 'org-special-keyword t)) 4673 (list (concat "\\[#[A-Z0-9]\\]") '(0 'org-special-keyword t))
4583 ;; Special keywords 4674 ;; Special keywords
4584 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t)) 4675 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
4585 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t)) 4676 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
4586 (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t)) 4677 (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t))
4587 (list (concat "\\<" org-archived-string) '(0 'org-special-keyword t))
4588 (list (concat "\\<" org-clock-string) '(0 'org-special-keyword t)) 4678 (list (concat "\\<" org-clock-string) '(0 'org-special-keyword t))
4589 ;; Emphasis 4679 ;; Emphasis
4590 (if em 4680 (if em
@@ -4602,25 +4692,13 @@ between words."
4602 "\\|" org-quote-string "\\)\\>") 4692 "\\|" org-quote-string "\\)\\>")
4603 '(1 'org-special-keyword t)) 4693 '(1 'org-special-keyword t))
4604 '("^#.*" (0 'font-lock-comment-face t)) 4694 '("^#.*" (0 'font-lock-comment-face t))
4605 ;; DONE 4695 ;; Code
4606 (if org-fontify-done-headline 4696 '("^[ \t]*\\(:.*\\)" (1 'org-code t))
4607 (list (concat "^[*]+ +\\<\\(" 4697 ;; Table internals
4608 (mapconcat 'regexp-quote org-done-keywords "\\|")
4609 "\\)\\(.*\\)")
4610 '(1 'org-done t) '(2 'org-headline-done t))
4611 (list (concat "^[*]+ +\\<\\("
4612 (mapconcat 'regexp-quote org-done-keywords "\\|")
4613 "\\)\\>")
4614 '(1 'org-done t)))
4615 ;; Table stuff
4616 '("^[ \t]*\\(:.*\\)" (1 'org-table t))
4617 '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t)) 4698 '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t))
4618; '("^[ \t]*| *\\([#!$*_^/]\\) *|" (1 'org-formula t))
4619 '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t)) 4699 '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
4620 '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t)) 4700 '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
4621 ;; Drawers 4701 ;; Drawers
4622; (list org-drawer-regexp '(0 'org-drawer t))
4623; (list "^[ \t]*:END:" '(0 'org-drawer t))
4624 (list org-drawer-regexp '(0 'org-special-keyword t)) 4702 (list org-drawer-regexp '(0 'org-special-keyword t))
4625 (list "^[ \t]*:END:" '(0 'org-special-keyword t)) 4703 (list "^[ \t]*:END:" '(0 'org-special-keyword t))
4626 ;; Properties 4704 ;; Properties
@@ -4651,6 +4729,15 @@ between words."
4651 ((eq n 2) org-f) 4729 ((eq n 2) org-f)
4652 (t (if org-level-color-stars-only nil org-f)))) 4730 (t (if org-level-color-stars-only nil org-f))))
4653 4731
4732
4733(defun org-get-todo-face (kwd)
4734 "Get the right face for a TODO keyword KWD.
4735If KWD is a number, get the corresponding match group."
4736 (if (numberp kwd) (setq kwd (match-string kwd)))
4737 (or (cdr (assoc kwd org-todo-keyword-faces))
4738 (and (member kwd org-done-keywords) 'org-done)
4739 'org-todo))
4740
4654(defun org-unfontify-region (beg end &optional maybe_loudly) 4741(defun org-unfontify-region (beg end &optional maybe_loudly)
4655 "Remove fontification and activation overlays from links." 4742 "Remove fontification and activation overlays from links."
4656 (font-lock-default-unfontify-region beg end) 4743 (font-lock-default-unfontify-region beg end)
@@ -4699,7 +4786,8 @@ between words."
4699 `org-cycle-emulate-tab' for details. 4786 `org-cycle-emulate-tab' for details.
4700 4787
4701- Special case: if point is at the beginning of the buffer and there is 4788- Special case: if point is at the beginning of the buffer and there is
4702 no headline in line 1, this function will act as if called with prefix arg." 4789 no headline in line 1, this function will act as if called with prefix arg.
4790 But only if also the variable `org-cycle-global-at-bob' is t."
4703 (interactive "P") 4791 (interactive "P")
4704 (let* ((outline-regexp 4792 (let* ((outline-regexp
4705 (if (and (org-mode-p) org-cycle-include-plain-lists) 4793 (if (and (org-mode-p) org-cycle-include-plain-lists)
@@ -4756,7 +4844,7 @@ between words."
4756 (setq org-cycle-global-status 'overview) 4844 (setq org-cycle-global-status 'overview)
4757 (run-hook-with-args 'org-cycle-hook 'overview)))) 4845 (run-hook-with-args 'org-cycle-hook 'overview))))
4758 4846
4759 ((and org-drawers 4847 ((and org-drawers org-drawer-regexp
4760 (save-excursion 4848 (save-excursion
4761 (beginning-of-line 1) 4849 (beginning-of-line 1)
4762 (looking-at org-drawer-regexp))) 4850 (looking-at org-drawer-regexp)))
@@ -5752,6 +5840,8 @@ WITH-CASE, the sorting considers case as well. With two prefix arguments
5752 nentries 5840 nentries
5753 (if unique (format ", %d duplicates removed" nremoved) "")))) 5841 (if unique (format ", %d duplicates removed" nremoved) ""))))
5754 5842
5843(defvar org-priority-regexp) ; defined later in the file
5844
5755(defun org-do-sort (table what &optional with-case sorting-type) 5845(defun org-do-sort (table what &optional with-case sorting-type)
5756 "Sort TABLE of WHAT according to SORTING-TYPE. 5846 "Sort TABLE of WHAT according to SORTING-TYPE.
5757The user will be prompted for the SORTING-TYPE if the call to this 5847The user will be prompted for the SORTING-TYPE if the call to this
@@ -5761,7 +5851,7 @@ the car of the elements of the table.
5761If WITH-CASE is non-nil, the sorting will be case-sensitive." 5851If WITH-CASE is non-nil, the sorting will be case-sensitive."
5762 (unless sorting-type 5852 (unless sorting-type
5763 (message 5853 (message
5764 "Sort %s: [a]lphabetically [n]umerically [t]ime. A/N/T means reversed:" 5854 "Sort %s: [a]lphabetic. [n]umeric. [t]ime [p]riority. A/N/T/P means reversed:"
5765 what) 5855 what)
5766 (setq sorting-type (read-char-exclusive))) 5856 (setq sorting-type (read-char-exclusive)))
5767 (let ((dcst (downcase sorting-type)) 5857 (let ((dcst (downcase sorting-type))
@@ -5785,6 +5875,13 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
5785 (org-time-string-to-time (match-string 0 x))) 5875 (org-time-string-to-time (match-string 0 x)))
5786 0)) 5876 0))
5787 comparefun (if (= dcst sorting-type) '< '>))) 5877 comparefun (if (= dcst sorting-type) '< '>)))
5878 ((= dcst ?p)
5879 (setq extractfun
5880 (lambda (x)
5881 (if (string-match org-priority-regexp x)
5882 (string-to-char (match-string 2 x))
5883 org-default-priority))
5884 comparefun (if (= dcst sorting-type) '< '>)))
5788 (t (error "Invalid sorting type `%c'" sorting-type))) 5885 (t (error "Invalid sorting type `%c'" sorting-type)))
5789 5886
5790 (sort (mapcar (lambda (x) (cons (funcall extractfun (car x)) (cdr x))) 5887 (sort (mapcar (lambda (x) (cons (funcall extractfun (car x)) (cdr x)))
@@ -6590,7 +6687,12 @@ this heading."
6590 (this-buffer (current-buffer)) 6687 (this-buffer (current-buffer))
6591 (org-archive-location org-archive-location) 6688 (org-archive-location org-archive-location)
6592 (re "^#\\+ARCHIVE:[ \t]+\\(\\S-.*\\S-\\)[ \t]*$") 6689 (re "^#\\+ARCHIVE:[ \t]+\\(\\S-.*\\S-\\)[ \t]*$")
6593 file heading buffer level newfile-p) 6690 (file (abbreviate-file-name (buffer-file-name)))
6691 (time (format-time-string
6692 (substring (cdr org-time-stamp-formats) 1 -1)
6693 (current-time)))
6694 afile heading buffer level newfile-p
6695 category todo priority ltags itags)
6594 6696
6595 ;; Try to find a local archive location 6697 ;; Try to find a local archive location
6596 (save-excursion 6698 (save-excursion
@@ -6601,21 +6703,31 @@ this heading."
6601 6703
6602 (if (string-match "\\(.*\\)::\\(.*\\)" org-archive-location) 6704 (if (string-match "\\(.*\\)::\\(.*\\)" org-archive-location)
6603 (progn 6705 (progn
6604 (setq file (format (match-string 1 org-archive-location) 6706 (setq afile (format (match-string 1 org-archive-location)
6605 (file-name-nondirectory buffer-file-name)) 6707 (file-name-nondirectory buffer-file-name))
6606 heading (match-string 2 org-archive-location))) 6708 heading (match-string 2 org-archive-location)))
6607 (error "Invalid `org-archive-location'")) 6709 (error "Invalid `org-archive-location'"))
6608 (if (> (length file) 0) 6710 (if (> (length afile) 0)
6609 (setq newfile-p (not (file-exists-p file)) 6711 (setq newfile-p (not (file-exists-p afile))
6610 buffer (find-file-noselect file)) 6712 buffer (find-file-noselect afile))
6611 (setq buffer (current-buffer))) 6713 (setq buffer (current-buffer)))
6612 (unless buffer 6714 (unless buffer
6613 (error "Cannot access file \"%s\"" file)) 6715 (error "Cannot access file \"%s\"" afile))
6614 (if (and (> (length heading) 0) 6716 (if (and (> (length heading) 0)
6615 (string-match "^\\*+" heading)) 6717 (string-match "^\\*+" heading))
6616 (setq level (match-end 0)) 6718 (setq level (match-end 0))
6617 (setq heading nil level 0)) 6719 (setq heading nil level 0))
6618 (save-excursion 6720 (save-excursion
6721 (org-back-to-heading t)
6722 ;; Get context information that will be lost by moving the tree
6723 (setq category (org-get-category)
6724 todo (and (looking-at org-todo-line-regexp)
6725 (match-string 2))
6726 priority (org-get-priority (if (match-end 3) (match-string 3) ""))
6727 ltags (org-split-string (org-get-tags) ":")
6728 itags (org-delete-all ltags (org-get-tags-at)))
6729 (setq ltags (mapconcat 'identity ltags " ")
6730 itags (mapconcat 'identity itags " "))
6619 ;; We first only copy, in case something goes wrong 6731 ;; We first only copy, in case something goes wrong
6620 ;; we need to protect this-command, to avoid kill-region sets it, 6732 ;; we need to protect this-command, to avoid kill-region sets it,
6621 ;; which would lead to duplication of subtrees 6733 ;; which would lead to duplication of subtrees
@@ -6676,9 +6788,15 @@ this heading."
6676 (car (or (member org-archive-mark-done org-done-keywords) 6788 (car (or (member org-archive-mark-done org-done-keywords)
6677 org-done-keywords))))) 6789 org-done-keywords)))))
6678 6790
6679 ;; Move cursor to right after the TODO keyword 6791 ;; Add the context info
6680 (when org-archive-stamp-time 6792 (when org-archive-save-context-info
6681 (org-add-planning-info 'archived (org-current-time))) 6793 (let ((l org-archive-save-context-info) e n v)
6794 (while (setq e (pop l))
6795 (when (and (setq v (symbol-value e))
6796 (stringp v) (string-match "\\S-" v))
6797 (setq n (concat "ARCHIVE_" (upcase (symbol-name e))))
6798 (org-entry-put (point) n v)))))
6799
6682 ;; Save the buffer, if it is not the same buffer. 6800 ;; Save the buffer, if it is not the same buffer.
6683 (if (not (eq this-buffer buffer)) (save-buffer)))) 6801 (if (not (eq this-buffer buffer)) (save-buffer))))
6684 ;; Here we are back in the original buffer. Everything seems to have 6802 ;; Here we are back in the original buffer. Everything seems to have
@@ -6688,7 +6806,7 @@ this heading."
6688 (message "Subtree archived %s" 6806 (message "Subtree archived %s"
6689 (if (eq this-buffer buffer) 6807 (if (eq this-buffer buffer)
6690 (concat "under heading: " heading) 6808 (concat "under heading: " heading)
6691 (concat "in file: " (abbreviate-file-name file))))))) 6809 (concat "in file: " (abbreviate-file-name afile)))))))
6692 6810
6693(defun org-archive-all-done (&optional tag) 6811(defun org-archive-all-done (&optional tag)
6694 "Archive sublevels of the current tree without open TODO items. 6812 "Archive sublevels of the current tree without open TODO items.
@@ -6735,7 +6853,8 @@ When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag."
6735 6853
6736(defun org-cycle-hide-drawers (state) 6854(defun org-cycle-hide-drawers (state)
6737 "Re-hide all drawers after a visibility state change." 6855 "Re-hide all drawers after a visibility state change."
6738 (when (not (memq state '(overview folded))) 6856 (when (and (org-mode-p)
6857 (not (memq state '(overview folded))))
6739 (save-excursion 6858 (save-excursion
6740 (let* ((globalp (memq state '(contents all))) 6859 (let* ((globalp (memq state '(contents all)))
6741 (beg (if globalp (point-min) (point))) 6860 (beg (if globalp (point-min) (point)))
@@ -8127,7 +8246,7 @@ it can be edited in place."
8127 (field (org-table-get-field)) 8246 (field (org-table-get-field))
8128 (cw (current-window-configuration)) 8247 (cw (current-window-configuration))
8129 p) 8248 p)
8130 (switch-to-buffer-other-window "*Org tmp*") 8249 (org-switch-to-buffer-other-window "*Org tmp*")
8131 (erase-buffer) 8250 (erase-buffer)
8132 (insert "#\n# Edit field and finish with C-c C-c\n#\n") 8251 (insert "#\n# Edit field and finish with C-c C-c\n#\n")
8133 (let ((org-inhibit-startup t)) (org-mode)) 8252 (let ((org-inhibit-startup t)) (org-mode))
@@ -9223,7 +9342,7 @@ Parameters get priority."
9223 (field . "# Field Formulas\n") 9342 (field . "# Field Formulas\n")
9224 (named . "# Named Field Formulas\n"))) 9343 (named . "# Named Field Formulas\n")))
9225 entry s type title) 9344 entry s type title)
9226 (switch-to-buffer-other-window "*Edit Formulas*") 9345 (org-switch-to-buffer-other-window "*Edit Formulas*")
9227 (erase-buffer) 9346 (erase-buffer)
9228 ;; Keep global-font-lock-mode from turning on font-lock-mode 9347 ;; Keep global-font-lock-mode from turning on font-lock-mode
9229 (let ((font-lock-global-modes '(not fundamental-mode))) 9348 (let ((font-lock-global-modes '(not fundamental-mode)))
@@ -9578,7 +9697,7 @@ With prefix ARG, apply the new formulas to the table."
9578 (if (and (markerp pos) (marker-buffer pos)) 9697 (if (and (markerp pos) (marker-buffer pos))
9579 (if (get-buffer-window (marker-buffer pos)) 9698 (if (get-buffer-window (marker-buffer pos))
9580 (select-window (get-buffer-window (marker-buffer pos))) 9699 (select-window (get-buffer-window (marker-buffer pos)))
9581 (switch-to-buffer-other-window (get-buffer-window 9700 (org-switch-to-buffer-other-window (get-buffer-window
9582 (marker-buffer pos))))) 9701 (marker-buffer pos)))))
9583 (goto-char pos) 9702 (goto-char pos)
9584 (org-table-force-dataline) 9703 (org-table-force-dataline)
@@ -10799,7 +10918,7 @@ For file links, arg negates `org-context-in-file-links'."
10799 (setq org-stored-links 10918 (setq org-stored-links
10800 (cons (list cpltxt link desc) org-stored-links)) 10919 (cons (list cpltxt link desc) org-stored-links))
10801 (message "Stored: %s" (or cpltxt link))) 10920 (message "Stored: %s" (or cpltxt link)))
10802 (org-make-link-string link desc)))) 10921 (and link (org-make-link-string link desc)))))
10803 10922
10804(defun org-store-link-props (&rest plist) 10923(defun org-store-link-props (&rest plist)
10805 "Store link properties, extract names and addresses." 10924 "Store link properties, extract names and addresses."
@@ -10873,6 +10992,8 @@ according to FMT (default from `org-email-link-description-format')."
10873 10992
10874(defun org-make-link-string (link &optional description) 10993(defun org-make-link-string (link &optional description)
10875 "Make a link with brackets, consisting of LINK and DESCRIPTION." 10994 "Make a link with brackets, consisting of LINK and DESCRIPTION."
10995 (unless (string-match "\\S-" link)
10996 (error "Empty link"))
10876 (when (stringp description) 10997 (when (stringp description)
10877 ;; Remove brackets from the description, they are fatal. 10998 ;; Remove brackets from the description, they are fatal.
10878 (while (string-match "\\[\\|\\]" description) 10999 (while (string-match "\\[\\|\\]" description)
@@ -10888,14 +11009,22 @@ according to FMT (default from `org-email-link-description-format')."
10888 "]")) 11009 "]"))
10889 11010
10890(defconst org-link-escape-chars 11011(defconst org-link-escape-chars
10891 '((" " . "%20") ("\340" . "%E0") 11012 '((" " . "%20")
10892 ("\342" . "%E2") ("\347" . "%E7") 11013 ("\340" . "%E0") ; `a
10893 ("\350" . "%E8") ("\351" . "%E9") 11014 ("\342" . "%E2") ; ^a
10894 ("\352" . "%EA") ("\356" . "%EE") 11015 ("\347" . "%E7") ; ,c
10895 ("\364" . "%F4") ("\371" . "%F9") 11016 ("\350" . "%E8") ; `e
10896 ("\373" . "%FB") (";" . "%3B") 11017 ("\351" . "%E9") ; 'e
10897 ("?" . "%3F") ("=" . "%3D") 11018 ("\352" . "%EA") ; ^e
10898 ("+" . "%2B")) 11019 ("\356" . "%EE") ; ^i
11020 ("\364" . "%F4") ; ^o
11021 ("\371" . "%F9") ; `u
11022 ("\373" . "%FB") ; ^u
11023 (";" . "%3B")
11024 ("?" . "%3F")
11025 ("=" . "%3D")
11026 ("+" . "%2B")
11027 )
10899 "Association list of escapes for some characters problematic in links.") 11028 "Association list of escapes for some characters problematic in links.")
10900 11029
10901(defun org-link-escape (text) 11030(defun org-link-escape (text)
@@ -10963,8 +11092,7 @@ according to FMT (default from `org-email-link-description-format')."
10963;;;###autoload 11092;;;###autoload
10964(defun org-insert-link-global () 11093(defun org-insert-link-global ()
10965 "Insert a link like Org-mode does. 11094 "Insert a link like Org-mode does.
10966This command can be called in any mode to follow a link that has 11095This command can be called in any mode to insert a link in Org-mode syntax."
10967Org-mode syntax."
10968 (interactive) 11096 (interactive)
10969 (org-run-like-in-org-mode 'org-insert-link)) 11097 (org-run-like-in-org-mode 'org-insert-link))
10970 11098
@@ -11774,12 +11902,13 @@ sequences, it will now work."
11774 (string= mh-index-folder (substring folder 0 end-index))) 11902 (string= mh-index-folder (substring folder 0 end-index)))
11775 (if (equal major-mode 'mh-show-mode) 11903 (if (equal major-mode 'mh-show-mode)
11776 (save-window-excursion 11904 (save-window-excursion
11777 (when (buffer-live-p (get-buffer folder)) 11905 (let (pop-up-frames)
11778 (progn 11906 (when (buffer-live-p (get-buffer folder))
11779 (pop-to-buffer folder) 11907 (progn
11780 (org-mhe-get-message-folder-from-index) 11908 (pop-to-buffer folder)
11781 ) 11909 (org-mhe-get-message-folder-from-index)
11782 )) 11910 )
11911 )))
11783 (org-mhe-get-message-folder-from-index) 11912 (org-mhe-get-message-folder-from-index)
11784 ) 11913 )
11785 folder 11914 folder
@@ -12065,9 +12194,11 @@ to be run from that hook to fucntion properly."
12065 (erase-buffer) 12194 (erase-buffer)
12066 (insert (substitute-command-keys 12195 (insert (substitute-command-keys
12067 (format 12196 (format
12068 "## `C-c C-c' to file interactively, `C-u C-c C-c' to file directly. 12197 "## `%sC-c C-c' to file directly, `%sC-c C-c' to file interactively.
12069## Target file \"%s\", headline \"%s\" 12198## Target file \"%s\", headline \"%s\"
12070## To switch templates, use `\\[org-remember]'.\n\n" 12199## To switch templates, use `\\[org-remember]'.\n\n"
12200 (if org-remember-store-without-prompt "" "C-u ")
12201 (if org-remember-store-without-prompt "C-u " "")
12071 (abbreviate-file-name (or file org-default-notes-file)) 12202 (abbreviate-file-name (or file org-default-notes-file))
12072 (or headline "")))) 12203 (or headline ""))))
12073 (insert tpl) (goto-char (point-min)) 12204 (insert tpl) (goto-char (point-min))
@@ -12544,6 +12675,8 @@ At all other locations, this simply calls `ispell-complete-word'."
12544If the last change removed the TODO tag or switched to DONE, then 12675If the last change removed the TODO tag or switched to DONE, then
12545this is nil.") 12676this is nil.")
12546 12677
12678(defvar org-setting-tags nil) ; dynamically skiped
12679
12547(defun org-todo (&optional arg) 12680(defun org-todo (&optional arg)
12548 "Change the TODO state of an item. 12681 "Change the TODO state of an item.
12549The state of an item is given by a keyword at the start of the heading, 12682The state of an item is given by a keyword at the start of the heading,
@@ -12658,11 +12791,13 @@ For calling through lisp, arg is also interpreted in the following way:
12658 (org-add-log-maybe 'state state 'findpos)) 12791 (org-add-log-maybe 'state state 'findpos))
12659 ((member state org-done-keywords) 12792 ((member state org-done-keywords)
12660 ;; Planning info calls the note-setting command. 12793 ;; Planning info calls the note-setting command.
12661 (org-add-planning-info 'closed (org-current-time) 12794 ;; FIXME: We used to remove scheduling info....
12662 (if (org-get-repeat) nil 'scheduled)) 12795; (org-add-planning-info 'closed (org-current-time)
12796; (if (org-get-repeat) nil 'scheduled))
12797 (org-add-planning-info 'closed (org-current-time))
12663 (org-add-log-maybe 'done state 'findpos)))) 12798 (org-add-log-maybe 'done state 'findpos))))
12664 ;; Fixup tag positioning 12799 ;; Fixup tag positioning
12665 (and org-auto-align-tags (org-set-tags nil t)) 12800 (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t))
12666 (run-hooks 'org-after-todo-state-change-hook) 12801 (run-hooks 'org-after-todo-state-change-hook)
12667 (and (member state org-done-keywords) (org-auto-repeat-maybe)) 12802 (and (member state org-done-keywords) (org-auto-repeat-maybe))
12668 (if (and arg (not (member state org-done-keywords))) 12803 (if (and arg (not (member state org-done-keywords)))
@@ -12844,8 +12979,7 @@ be removed."
12844 (if (not (equal (char-before) ?\ )) " " "") 12979 (if (not (equal (char-before) ?\ )) " " "")
12845 (cond ((eq what 'scheduled) org-scheduled-string) 12980 (cond ((eq what 'scheduled) org-scheduled-string)
12846 ((eq what 'deadline) org-deadline-string) 12981 ((eq what 'deadline) org-deadline-string)
12847 ((eq what 'closed) org-closed-string) 12982 ((eq what 'closed) org-closed-string))
12848 ((eq what 'archived) org-archived-string))
12849 " ") 12983 " ")
12850 (org-insert-time-stamp 12984 (org-insert-time-stamp
12851 time 12985 time
@@ -12881,17 +13015,22 @@ The auto-repeater uses this.")
12881 "[^\r\n]*\\)?")) 13015 "[^\r\n]*\\)?"))
12882 (goto-char (match-end 0)) 13016 (goto-char (match-end 0))
12883 (unless org-log-states-order-reversed 13017 (unless org-log-states-order-reversed
12884 (if (looking-at "\n[ \t]*- State") (forward-char 1)) 13018 (and (= (char-after) ?\n) (forward-char 1))
12885 (while (looking-at "[ \t]*- State") 13019 (org-skip-over-state-notes)
12886 (condition-case nil
12887 (org-next-item)
12888 (error (org-end-of-item))))
12889 (skip-chars-backward " \t\n\r"))) 13020 (skip-chars-backward " \t\n\r")))
12890 (move-marker org-log-note-marker (point)) 13021 (move-marker org-log-note-marker (point))
12891 (setq org-log-note-purpose purpose) 13022 (setq org-log-note-purpose purpose)
12892 (setq org-log-note-state state) 13023 (setq org-log-note-state state)
12893 (add-hook 'post-command-hook 'org-add-log-note 'append)))) 13024 (add-hook 'post-command-hook 'org-add-log-note 'append))))
12894 13025
13026(defun org-skip-over-state-notes ()
13027 "Skip past the list of State notes in an entry."
13028 (if (looking-at "\n[ \t]*- State") (forward-char 1))
13029 (while (looking-at "[ \t]*- State")
13030 (condition-case nil
13031 (org-next-item)
13032 (error (org-end-of-item)))))
13033
12895(defun org-add-log-note (&optional purpose) 13034(defun org-add-log-note (&optional purpose)
12896 "Pop up a window for taking a note, and add this note later at point." 13035 "Pop up a window for taking a note, and add this note later at point."
12897 (remove-hook 'post-command-hook 'org-add-log-note) 13036 (remove-hook 'post-command-hook 'org-add-log-note)
@@ -12900,7 +13039,7 @@ The auto-repeater uses this.")
12900 (move-marker org-log-note-return-to (point)) 13039 (move-marker org-log-note-return-to (point))
12901 (switch-to-buffer (marker-buffer org-log-note-marker)) 13040 (switch-to-buffer (marker-buffer org-log-note-marker))
12902 (goto-char org-log-note-marker) 13041 (goto-char org-log-note-marker)
12903 (switch-to-buffer-other-window "*Org Note*") 13042 (org-switch-to-buffer-other-window "*Org Note*")
12904 (erase-buffer) 13043 (erase-buffer)
12905 (let ((org-inhibit-startup t)) (org-mode)) 13044 (let ((org-inhibit-startup t)) (org-mode))
12906 (insert (format "# Insert note for %s, finish with C-c C-c.\n\n" 13045 (insert (format "# Insert note for %s, finish with C-c C-c.\n\n"
@@ -13382,6 +13521,8 @@ With prefix ARG, realign all tags in headings in the current buffer."
13382 (interactive "P") 13521 (interactive "P")
13383 (let* ((re (concat "^" outline-regexp)) 13522 (let* ((re (concat "^" outline-regexp))
13384 (current (org-get-tags)) 13523 (current (org-get-tags))
13524 (col (current-column))
13525 (org-setting-tags t)
13385 table current-tags inherited-tags ; computed below when needed 13526 table current-tags inherited-tags ; computed below when needed
13386 tags p0 c0 c1 rpl) 13527 tags p0 c0 c1 rpl)
13387 (if arg 13528 (if arg
@@ -13406,7 +13547,8 @@ With prefix ARG, realign all tags in headings in the current buffer."
13406 (if (or (eq t org-use-fast-tag-selection) 13547 (if (or (eq t org-use-fast-tag-selection)
13407 (and org-use-fast-tag-selection 13548 (and org-use-fast-tag-selection
13408 (delq nil (mapcar 'cdr table)))) 13549 (delq nil (mapcar 'cdr table))))
13409 (org-fast-tag-selection current-tags inherited-tags table) 13550 (org-fast-tag-selection current-tags inherited-tags
13551 table org-todo-tag-alist)
13410 (let ((org-add-colon-after-tag-completion t)) 13552 (let ((org-add-colon-after-tag-completion t))
13411 (org-trim 13553 (org-trim
13412 (completing-read "Tags: " 'org-tags-completion-function 13554 (completing-read "Tags: " 'org-tags-completion-function
@@ -13438,7 +13580,47 @@ With prefix ARG, realign all tags in headings in the current buffer."
13438 (replace-match rpl t t) 13580 (replace-match rpl t t)
13439 (and (not (featurep 'xemacs)) c0 (tabify p0 (point))) 13581 (and (not (featurep 'xemacs)) c0 (tabify p0 (point)))
13440 tags) 13582 tags)
13441 (t (error "Tags alignment failed")))))) 13583 (t (error "Tags alignment failed")))
13584 (move-to-column col))))
13585
13586(defun org-change-tag-in-region (beg end tag off)
13587 "Add or remove TAG for each entry in the region.
13588This works in the agenda, and also in an org-mode buffer."
13589 (interactive
13590 (list (region-beginning) (region-end)
13591 (let ((org-last-tags-completion-table
13592 (if (org-mode-p)
13593 (org-get-buffer-tags)
13594 (org-global-tags-completion-table))))
13595 (completing-read
13596 "Tag: " 'org-tags-completion-function nil nil nil
13597 'org-tags-history))
13598 (progn
13599 (message "[s]et or [r]emove? ")
13600 (equal (read-char-exclusive) ?r))))
13601 (if (fboundp 'deactivate-mark) (deactivate-mark))
13602 (let ((agendap (equal major-mode 'org-agenda-mode))
13603 l1 l2 m buf pos newhead (cnt 0))
13604 (goto-char end)
13605 (setq l2 (1- (org-current-line)))
13606 (goto-char beg)
13607 (setq l1 (org-current-line))
13608 (loop for l from l1 to l2 do
13609 (goto-line l)
13610 (setq m (get-text-property (point) 'org-hd-marker))
13611 (when (or (and (org-mode-p) (org-on-heading-p))
13612 (and agendap m))
13613 (setq buf (if agendap (marker-buffer m) (current-buffer))
13614 pos (if agendap m (point)))
13615 (with-current-buffer buf
13616 (save-excursion
13617 (save-restriction
13618 (goto-char pos)
13619 (setq cnt (1+ cnt))
13620 (org-toggle-tag tag (if off 'off 'on))
13621 (setq newhead (org-get-heading)))))
13622 (and agendap (org-agenda-change-all-lines newhead m))))
13623 (message "Tag :%s: %s in %d headings" tag (if off "removed" "set") cnt)))
13442 13624
13443(defun org-tags-completion-function (string predicate &optional flag) 13625(defun org-tags-completion-function (string predicate &optional flag)
13444 (let (s1 s2 rtn (ctable org-last-tags-completion-table) 13626 (let (s1 s2 rtn (ctable org-last-tags-completion-table)
@@ -13491,17 +13673,19 @@ With prefix ARG, realign all tags in headings in the current buffer."
13491 (put-text-property 0 (length s) 'face '(secondary-selection org-tag) s) 13673 (put-text-property 0 (length s) 'face '(secondary-selection org-tag) s)
13492 (org-overlay-display org-tags-overlay (concat prefix s))))) 13674 (org-overlay-display org-tags-overlay (concat prefix s)))))
13493 13675
13494(defun org-fast-tag-selection (current inherited table) 13676(defun org-fast-tag-selection (current inherited table &optional todo-table)
13495 "Fast tag selection with single keys. 13677 "Fast tag selection with single keys.
13496CURRENT is the current list of tags in the headline, INHERITED is the 13678CURRENT is the current list of tags in the headline, INHERITED is the
13497list of inherited tags, and TABLE is an alist of tags and corresponding keys, 13679list of inherited tags, and TABLE is an alist of tags and corresponding keys,
13498possibly with grouping information. 13680possibly with grouping information. TODO-TABLE is a similar table with
13681TODO keywords, should these have keys assigned to them.
13499If the keys are nil, a-z are automatically assigned. 13682If the keys are nil, a-z are automatically assigned.
13500Returns the new tags string, or nil to not change the current settings." 13683Returns the new tags string, or nil to not change the current settings."
13501 (let* ((maxlen (apply 'max (mapcar 13684 (let* ((fulltable (append table todo-table))
13685 (maxlen (apply 'max (mapcar
13502 (lambda (x) 13686 (lambda (x)
13503 (if (stringp (car x)) (string-width (car x)) 0)) 13687 (if (stringp (car x)) (string-width (car x)) 0))
13504 table))) 13688 fulltable)))
13505 (buf (current-buffer)) 13689 (buf (current-buffer))
13506 (expert (eq org-fast-tag-selection-single-key 'expert)) 13690 (expert (eq org-fast-tag-selection-single-key 'expert))
13507 (buffer-tags nil) 13691 (buffer-tags nil)
@@ -13535,13 +13719,13 @@ Returns the new tags string, or nil to not change the current settings."
13535 (set-buffer (get-buffer-create " *Org tags*")) 13719 (set-buffer (get-buffer-create " *Org tags*"))
13536 (delete-other-windows) 13720 (delete-other-windows)
13537 (split-window-vertically) 13721 (split-window-vertically)
13538 (switch-to-buffer-other-window (get-buffer-create " *Org tags*"))) 13722 (org-switch-to-buffer-other-window (get-buffer-create " *Org tags*")))
13539 (erase-buffer) 13723 (erase-buffer)
13540 (org-fast-tag-insert "Inherited" inherited i-face "\n") 13724 (org-fast-tag-insert "Inherited" inherited i-face "\n")
13541 (org-fast-tag-insert "Current" current c-face "\n\n") 13725 (org-fast-tag-insert "Current" current c-face "\n\n")
13542 (org-fast-tag-show-exit exit-after-next) 13726 (org-fast-tag-show-exit exit-after-next)
13543 (org-set-current-tags-overlay current ov-prefix) 13727 (org-set-current-tags-overlay current ov-prefix)
13544 (setq tbl table char ?a cnt 0) 13728 (setq tbl fulltable char ?a cnt 0)
13545 (while (setq e (pop tbl)) 13729 (while (setq e (pop tbl))
13546 (cond 13730 (cond
13547 ((equal e '(:startgroup)) 13731 ((equal e '(:startgroup))
@@ -13605,7 +13789,7 @@ Returns the new tags string, or nil to not change the current settings."
13605 (setq expert nil) 13789 (setq expert nil)
13606 (delete-other-windows) 13790 (delete-other-windows)
13607 (split-window-vertically) 13791 (split-window-vertically)
13608 (switch-to-buffer-other-window " *Org tags*") 13792 (org-switch-to-buffer-other-window " *Org tags*")
13609 (and (fboundp 'fit-window-to-buffer) 13793 (and (fboundp 'fit-window-to-buffer)
13610 (fit-window-to-buffer)))) 13794 (fit-window-to-buffer))))
13611 ((or (= c ?\C-g) 13795 ((or (= c ?\C-g)
@@ -13629,6 +13813,10 @@ Returns the new tags string, or nil to not change the current settings."
13629 (setq current (delete tg current)) 13813 (setq current (delete tg current))
13630 (push tg current))) 13814 (push tg current)))
13631 (if exit-after-next (setq exit-after-next 'now))) 13815 (if exit-after-next (setq exit-after-next 'now)))
13816 ((setq e (rassoc c todo-table) tg (car e))
13817 (with-current-buffer buf
13818 (save-excursion (org-todo tg)))
13819 (if exit-after-next (setq exit-after-next 'now)))
13632 ((setq e (rassoc c ntable) tg (car e)) 13820 ((setq e (rassoc c ntable) tg (car e))
13633 (if (member tg current) 13821 (if (member tg current)
13634 (setq current (delete tg current)) 13822 (setq current (delete tg current))
@@ -13970,6 +14158,9 @@ If the property is not present at all, nil is returned."
13970 (while (re-search-forward re end t)) 14158 (while (re-search-forward re end t))
13971 (setq hiddenp (org-invisible-p)) 14159 (setq hiddenp (org-invisible-p))
13972 (end-of-line 1) 14160 (end-of-line 1)
14161 (and (= (char-after) ?\n) (forward-char 1))
14162 (org-skip-over-state-notes)
14163 (end-of-line 0)
13973 (insert "\n:PROPERTIES:\n:END:") 14164 (insert "\n:PROPERTIES:\n:END:")
13974 (beginning-of-line 0) 14165 (beginning-of-line 0)
13975 (org-indent-line-function) 14166 (org-indent-line-function)
@@ -16290,7 +16481,8 @@ The following commands are available:
16290 "--" 16481 "--"
16291 ("Tags and Properties" 16482 ("Tags and Properties"
16292 ["Show all Tags" org-agenda-show-tags t] 16483 ["Show all Tags" org-agenda-show-tags t]
16293 ["Set Tags" org-agenda-set-tags t] 16484 ["Set Tags current line" org-agenda-set-tags (not (org-region-active-p))]
16485 ["Change tag in region" org-agenda-set-tags (org-region-active-p)]
16294 "--" 16486 "--"
16295 ["Column View" org-columns t]) 16487 ["Column View" org-columns t])
16296 ("Date/Schedule" 16488 ("Date/Schedule"
@@ -16470,7 +16662,7 @@ next use of \\[org-agenda]) restricted to the current file."
16470 (setq org-agenda-last-dispatch-buffer (current-buffer)) 16662 (setq org-agenda-last-dispatch-buffer (current-buffer))
16471 (save-window-excursion 16663 (save-window-excursion
16472 (delete-other-windows) 16664 (delete-other-windows)
16473 (switch-to-buffer-other-window " *Agenda Commands*") 16665 (org-switch-to-buffer-other-window " *Agenda Commands*")
16474 (erase-buffer) 16666 (erase-buffer)
16475 (insert (eval-when-compile 16667 (insert (eval-when-compile
16476 (let ((header 16668 (let ((header
@@ -16649,7 +16841,7 @@ before running the agenda command."
16649 (list 'org-tags-view nil cmd-key))) 16841 (list 'org-tags-view nil cmd-key)))
16650 (flet ((read-char-exclusive () (string-to-char cmd-key))) 16842 (flet ((read-char-exclusive () (string-to-char cmd-key)))
16651 (eval (list 'let (nreverse pars) '(org-agenda nil))))) 16843 (eval (list 'let (nreverse pars) '(org-agenda nil)))))
16652 (set-buffer "*Org Agenda*") 16844 (set-buffer org-agenda-buffer-name)
16653 (princ (org-encode-for-stdout (buffer-string))))) 16845 (princ (org-encode-for-stdout (buffer-string)))))
16654 16846
16655(defun org-encode-for-stdout (string) 16847(defun org-encode-for-stdout (string)
@@ -16704,7 +16896,7 @@ agenda-day The day in the agenda where this is listed"
16704 (list 'org-tags-view nil cmd-key))) 16896 (list 'org-tags-view nil cmd-key)))
16705 (flet ((read-char-exclusive () (string-to-char cmd-key))) 16897 (flet ((read-char-exclusive () (string-to-char cmd-key)))
16706 (eval (list 'let (nreverse pars) '(org-agenda nil))))) 16898 (eval (list 'let (nreverse pars) '(org-agenda nil)))))
16707 (set-buffer "*Org Agenda*") 16899 (set-buffer org-agenda-buffer-name)
16708 (let* ((lines (org-split-string (buffer-string) "\n")) 16900 (let* ((lines (org-split-string (buffer-string) "\n"))
16709 line) 16901 line)
16710 (while (setq line (pop lines)) 16902 (while (setq line (pop lines))
@@ -16767,13 +16959,12 @@ agenda-day The day in the agenda where this is listed"
16767 (interactive) 16959 (interactive)
16768 (eval (list 'org-batch-store-agenda-views))) 16960 (eval (list 'org-batch-store-agenda-views)))
16769 16961
16770(defvar org-agenda-buffer-name)
16771
16772;; FIXME, why is this a macro????? 16962;; FIXME, why is this a macro?????
16773;;;###autoload 16963;;;###autoload
16774(defmacro org-batch-store-agenda-views (&rest parameters) 16964(defmacro org-batch-store-agenda-views (&rest parameters)
16775 "Run all custom agenda commands that have a file argument." 16965 "Run all custom agenda commands that have a file argument."
16776 (let ((cmds org-agenda-custom-commands) 16966 (let ((cmds org-agenda-custom-commands)
16967 (pop-up-frames nil)
16777 (dir default-directory) 16968 (dir default-directory)
16778 pars cmd thiscmdkey files opts) 16969 pars cmd thiscmdkey files opts)
16779 (while parameters 16970 (while parameters
@@ -16784,18 +16975,19 @@ agenda-day The day in the agenda where this is listed"
16784 (setq cmd (pop cmds) 16975 (setq cmd (pop cmds)
16785 thiscmdkey (car cmd) 16976 thiscmdkey (car cmd)
16786 opts (nth 3 cmd) 16977 opts (nth 3 cmd)
16787 files (org-last cmd)) 16978 files (nth 4 cmd))
16788 (if (stringp files) (setq files (list files))) 16979 (if (stringp files) (setq files (list files)))
16789 (when files 16980 (when files
16790 (flet ((read-char-exclusive () (string-to-char thiscmdkey))) 16981 (flet ((read-char-exclusive () (string-to-char thiscmdkey)))
16791 (eval (list 'let (append org-agenda-exporter-settings opts pars) 16982 (eval (list 'let (append org-agenda-exporter-settings opts pars)
16792 '(org-agenda nil)))) 16983 '(org-agenda nil))))
16793 (set-buffer "*Org Agenda*") 16984 (set-buffer org-agenda-buffer-name)
16794 (while files 16985 (while files
16795 (eval (list 'let (append org-agenda-exporter-settings opts pars) 16986 (eval (list 'let (append org-agenda-exporter-settings opts pars)
16796 (list 'org-write-agenda 16987 (list 'org-write-agenda
16797 (expand-file-name (pop files) dir) t))))) 16988 (expand-file-name (pop files) dir) t))))
16798 (kill-buffer org-agenda-buffer-name))))) 16989 (and (get-buffer org-agenda-buffer-name)
16990 (kill-buffer org-agenda-buffer-name)))))))
16799 16991
16800(defun org-write-agenda (file &optional nosettings) 16992(defun org-write-agenda (file &optional nosettings)
16801 "Write the current buffer (an agenda view) as a file. 16993 "Write the current buffer (an agenda view) as a file.
@@ -16863,11 +17055,19 @@ higher priority settings."
16863 "Get the list of agenda files. 17055 "Get the list of agenda files.
16864Optional UNRESTRICTED means return the full list even if a restriction 17056Optional UNRESTRICTED means return the full list even if a restriction
16865is currently in place." 17057is currently in place."
16866 (cond 17058 (let ((files
16867 ((and (not unrestricted) (get 'org-agenda-files 'org-restrict))) 17059 (cond
16868 ((stringp org-agenda-files) (org-read-agenda-file-list)) 17060 ((and (not unrestricted) (get 'org-agenda-files 'org-restrict)))
16869 ((listp org-agenda-files) org-agenda-files) 17061 ((stringp org-agenda-files) (org-read-agenda-file-list))
16870 (t (error "Invalid value of `org-agenda-files'")))) 17062 ((listp org-agenda-files) org-agenda-files)
17063 (t (error "Invalid value of `org-agenda-files'")))))
17064 (if org-agenda-skip-unavailable-files
17065 (delq nil
17066 (mapcar (function
17067 (lambda (file)
17068 (and (file-readable-p file) file)))
17069 files))
17070 files))) ; `org-check-agenda-file' will remove them from the list
16871 17071
16872(defun org-edit-agenda-file-list () 17072(defun org-edit-agenda-file-list ()
16873 "Edit the list of agenda files. 17073 "Edit the list of agenda files.
@@ -16937,7 +17137,8 @@ If the file is not present in the list, it is added to the front. If it is
16937present, it is moved there. With optional argument TO-END, add/move to the 17137present, it is moved there. With optional argument TO-END, add/move to the
16938end of the list." 17138end of the list."
16939 (interactive "P") 17139 (interactive "P")
16940 (let ((file-alist (mapcar (lambda (x) 17140 (let ((org-agenda-skip-unavailable-files nil)
17141 (file-alist (mapcar (lambda (x)
16941 (cons (file-truename x) x)) 17142 (cons (file-truename x) x))
16942 (org-agenda-files t))) 17143 (org-agenda-files t)))
16943 (ctf (file-truename buffer-file-name)) 17144 (ctf (file-truename buffer-file-name))
@@ -16958,7 +17159,8 @@ end of the list."
16958These are the files which are being checked for agenda entries. 17159These are the files which are being checked for agenda entries.
16959Optional argument FILE means, use this file instead of the current." 17160Optional argument FILE means, use this file instead of the current."
16960 (interactive) 17161 (interactive)
16961 (let* ((file (or file buffer-file-name)) 17162 (let* ((org-agenda-skip-unavailable-files nil)
17163 (file (or file buffer-file-name))
16962 (true-file (file-truename file)) 17164 (true-file (file-truename file))
16963 (afile (abbreviate-file-name file)) 17165 (afile (abbreviate-file-name file))
16964 (files (delq nil (mapcar 17166 (files (delq nil (mapcar
@@ -17020,12 +17222,12 @@ Optional argument FILE means, use this file instead of the current."
17020 ((equal org-agenda-window-setup 'current-window) 17222 ((equal org-agenda-window-setup 'current-window)
17021 (switch-to-buffer abuf)) 17223 (switch-to-buffer abuf))
17022 ((equal org-agenda-window-setup 'other-window) 17224 ((equal org-agenda-window-setup 'other-window)
17023 (switch-to-buffer-other-window abuf)) 17225 (org-switch-to-buffer-other-window abuf))
17024 ((equal org-agenda-window-setup 'other-frame) 17226 ((equal org-agenda-window-setup 'other-frame)
17025 (switch-to-buffer-other-frame abuf)) 17227 (switch-to-buffer-other-frame abuf))
17026 ((equal org-agenda-window-setup 'reorganize-frame) 17228 ((equal org-agenda-window-setup 'reorganize-frame)
17027 (delete-other-windows) 17229 (delete-other-windows)
17028 (switch-to-buffer-other-window abuf)))) 17230 (org-switch-to-buffer-other-window abuf))))
17029 (setq buffer-read-only nil) 17231 (setq buffer-read-only nil)
17030 (erase-buffer) 17232 (erase-buffer)
17031 (org-agenda-mode) 17233 (org-agenda-mode)
@@ -17233,7 +17435,7 @@ dates."
17233 s e rtn d emptyp) 17435 s e rtn d emptyp)
17234 (setq org-agenda-redo-command 17436 (setq org-agenda-redo-command
17235 (list 'progn 17437 (list 'progn
17236 (list 'switch-to-buffer-other-window (current-buffer)) 17438 (list 'org-switch-to-buffer-other-window (current-buffer))
17237 (list 'org-timeline (list 'quote include-all)))) 17439 (list 'org-timeline (list 'quote include-all))))
17238 (if (not dopast) 17440 (if (not dopast)
17239 ;; Remove past dates from the list of dates. 17441 ;; Remove past dates from the list of dates.
@@ -17688,10 +17890,10 @@ that can be put into `org-agenda-skip-function' for the duration of a command."
17688 (not (re-search-forward org-deadline-time-regexp end t))) 17890 (not (re-search-forward org-deadline-time-regexp end t)))
17689 (and (setq m (memq 'regexp conditions)) 17891 (and (setq m (memq 'regexp conditions))
17690 (stringp (setq r (nth 1 m))) 17892 (stringp (setq r (nth 1 m)))
17691 (re-search-forward m end t)) 17893 (re-search-forward (nth 1 m) end t))
17692 (and (setq m (memq 'notregexp conditions)) 17894 (and (setq m (memq 'notregexp conditions))
17693 (stringp (setq r (nth 1 m))) 17895 (stringp (setq r (nth 1 m)))
17694 (not (re-search-forward m end t)))) 17896 (not (re-search-forward (nth 1 m) end t))))
17695 end))) 17897 end)))
17696 17898
17697(defun org-agenda-list-stuck-projects (&rest ignore) 17899(defun org-agenda-list-stuck-projects (&rest ignore)
@@ -17748,6 +17950,7 @@ MATCH is being ignored."
17748 "Get the (Emacs Calendar) diary entries for DATE." 17950 "Get the (Emacs Calendar) diary entries for DATE."
17749 (let* ((fancy-diary-buffer "*temporary-fancy-diary-buffer*") 17951 (let* ((fancy-diary-buffer "*temporary-fancy-diary-buffer*")
17750 (diary-display-hook '(fancy-diary-display)) 17952 (diary-display-hook '(fancy-diary-display))
17953 (pop-up-frames nil)
17751 (list-diary-entries-hook 17954 (list-diary-entries-hook
17752 (cons 'org-diary-default-entry list-diary-entries-hook)) 17955 (cons 'org-diary-default-entry list-diary-entries-hook))
17753 (diary-file-name-prefix-function nil) ; turn this feature off 17956 (diary-file-name-prefix-function nil) ; turn this feature off
@@ -18018,7 +18221,7 @@ the documentation of `org-diary'."
18018 (and org-agenda-todo-ignore-deadlines (goto-char beg) 18221 (and org-agenda-todo-ignore-deadlines (goto-char beg)
18019 (re-search-forward org-deadline-time-regexp end t) 18222 (re-search-forward org-deadline-time-regexp end t)
18020 (org-deadline-close (match-string 1)))) 18223 (org-deadline-close (match-string 1))))
18021 (goto-char beg) 18224 (goto-char (1+ beg))
18022 (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible)) 18225 (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible))
18023 (throw :skip nil))) 18226 (throw :skip nil)))
18024 (goto-char beg) 18227 (goto-char beg)
@@ -18220,7 +18423,7 @@ the documentation of `org-diary'."
18220 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar 18423 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
18221 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar 18424 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
18222 d2 diff dfrac wdays pos pos1 category tags 18425 d2 diff dfrac wdays pos pos1 category tags
18223 ee txt head face s upcomingp) 18426 ee txt head face s upcomingp donep timestr)
18224 (goto-char (point-min)) 18427 (goto-char (point-min))
18225 (while (re-search-forward regexp nil t) 18428 (while (re-search-forward regexp nil t)
18226 (catch :skip 18429 (catch :skip
@@ -18255,14 +18458,20 @@ the documentation of `org-diary'."
18255 (point) 18458 (point)
18256 (progn (skip-chars-forward "^\r\n") 18459 (progn (skip-chars-forward "^\r\n")
18257 (point)))) 18460 (point))))
18258 (if (and org-agenda-skip-deadline-if-done 18461 (setq donep (string-match org-looking-at-done-regexp head))
18259 (string-match org-looking-at-done-regexp head)) 18462 (if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
18463 (setq timestr
18464 (concat (substring s (match-beginning 1)) " "))
18465 (setq timestr 'time))
18466 (if (and donep
18467 (or org-agenda-skip-deadline-if-done
18468 (not (= diff 0))))
18260 (setq txt nil) 18469 (setq txt nil)
18261 (setq txt (org-format-agenda-item 18470 (setq txt (org-format-agenda-item
18262 (if (= diff 0) 18471 (if (= diff 0)
18263 "Deadline: " 18472 "Deadline: "
18264 (format "In %3d d.: " diff)) 18473 (format "In %3d d.: " diff))
18265 head category tags)))) 18474 head category tags timestr))))
18266 (setq txt org-agenda-no-heading-message)) 18475 (setq txt org-agenda-no-heading-message))
18267 (when txt 18476 (when txt
18268 (setq face (org-agenda-deadline-face dfrac)) 18477 (setq face (org-agenda-deadline-face dfrac))
@@ -18274,7 +18483,8 @@ the documentation of `org-diary'."
18274 'org-category category 18483 'org-category category
18275 'type (if upcomingp "upcoming-deadline" "deadline") 18484 'type (if upcomingp "upcoming-deadline" "deadline")
18276 'date (if upcomingp date d2) 18485 'date (if upcomingp date d2)
18277 'face face 'undone-face face 'done-face 'org-done) 18486 'face (if donep 'org-done face)
18487 'undone-face face 'done-face 'org-done)
18278 (push txt ee)))))) 18488 (push txt ee))))))
18279 ee)) 18489 ee))
18280 18490
@@ -18300,15 +18510,16 @@ FRACTION is what fraction of the head-warning time has passed."
18300 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar 18510 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
18301 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar 18511 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
18302 d2 diff pos pos1 category tags 18512 d2 diff pos pos1 category tags
18303 ee txt head pastduep donep face) 18513 ee txt head pastschedp donep face timestr s)
18304 (goto-char (point-min)) 18514 (goto-char (point-min))
18305 (while (re-search-forward regexp nil t) 18515 (while (re-search-forward regexp nil t)
18306 (catch :skip 18516 (catch :skip
18307 (org-agenda-skip) 18517 (org-agenda-skip)
18308 (setq pos (1- (match-beginning 1)) 18518 (setq s (match-string 1)
18519 pos (1- (match-beginning 1))
18309 d2 (org-time-string-to-absolute (match-string 1) d1) 18520 d2 (org-time-string-to-absolute (match-string 1) d1)
18310 diff (- d2 d1)) 18521 diff (- d2 d1))
18311 (setq pastduep (and todayp (< diff 0))) 18522 (setq pastschedp (and todayp (< diff 0)))
18312 ;; When to show a scheduled item in the calendar: 18523 ;; When to show a scheduled item in the calendar:
18313 ;; If it is on or past the date. 18524 ;; If it is on or past the date.
18314 (if (or (and (< diff 0) todayp) 18525 (if (or (and (< diff 0) todayp)
@@ -18324,16 +18535,22 @@ FRACTION is what fraction of the head-warning time has passed."
18324 (point) 18535 (point)
18325 (progn (skip-chars-forward "^\r\n") (point)))) 18536 (progn (skip-chars-forward "^\r\n") (point))))
18326 (setq donep (string-match org-looking-at-done-regexp head)) 18537 (setq donep (string-match org-looking-at-done-regexp head))
18327 (if (and org-agenda-skip-scheduled-if-done donep) 18538 (if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
18539 (setq timestr
18540 (concat (substring s (match-beginning 1)) " "))
18541 (setq timestr 'time))
18542 (if (and donep
18543 (or org-agenda-skip-scheduled-if-done
18544 (not (= diff 0))))
18328 (setq txt nil) 18545 (setq txt nil)
18329 (setq txt (org-format-agenda-item 18546 (setq txt (org-format-agenda-item
18330 (if (= diff 0) 18547 (if (= diff 0)
18331 "Scheduled: " 18548 "Scheduled: "
18332 (format "Sched.%2dx: " (- 1 diff))) 18549 (format "Sched.%2dx: " (- 1 diff)))
18333 head category tags)))) 18550 head category tags timestr))))
18334 (setq txt org-agenda-no-heading-message)) 18551 (setq txt org-agenda-no-heading-message))
18335 (when txt 18552 (when txt
18336 (setq face (if pastduep 18553 (setq face (if pastschedp
18337 'org-scheduled-previously 18554 'org-scheduled-previously
18338 'org-scheduled-today)) 18555 'org-scheduled-today))
18339 (org-add-props txt props 18556 (org-add-props txt props
@@ -18341,8 +18558,8 @@ FRACTION is what fraction of the head-warning time has passed."
18341 'face (if donep 'org-done face) 18558 'face (if donep 'org-done face)
18342 'org-marker (org-agenda-new-marker pos) 18559 'org-marker (org-agenda-new-marker pos)
18343 'org-hd-marker (org-agenda-new-marker pos1) 18560 'org-hd-marker (org-agenda-new-marker pos1)
18344 'type (if pastduep "past-scheduled" "scheduled") 18561 'type (if pastschedp "past-scheduled" "scheduled")
18345 'date (if pastduep d2 date) 18562 'date (if pastschedp d2 date)
18346 'priority (+ (- 5 diff) (org-get-priority txt)) 18563 'priority (+ (- 5 diff) (org-get-priority txt))
18347 'org-category category) 18564 'org-category category)
18348 (push txt ee)))))) 18565 (push txt ee))))))
@@ -18646,16 +18863,18 @@ HH:MM."
18646 (if (eq x 'line) 18863 (if (eq x 'line)
18647 (save-excursion 18864 (save-excursion
18648 (beginning-of-line 1) 18865 (beginning-of-line 1)
18649 (setq re (get-text-property (point) 'org-not-done-regexp)) 18866 (setq re (get-text-property (point) 'org-todo-regexp))
18650 (goto-char (+ (point) (or (get-text-property (point) 'prefix-length) 0))) 18867 (goto-char (+ (point) (or (get-text-property (point) 'prefix-length) 0)))
18651 (and (looking-at (concat "[ \t]*\\.*" re)) 18868 (and (looking-at (concat "[ \t]*\\.*" re))
18652 (add-text-properties (match-beginning 0) (match-end 0) 18869 (add-text-properties (match-beginning 0) (match-end 0)
18653 '(face org-todo)))) 18870 (list 'face (org-get-todo-face 0)))))
18654 (setq re (concat (get-text-property 0 'org-not-done-regexp x)) 18871 (setq re (concat (get-text-property 0 'org-todo-regexp x))
18655 pl (get-text-property 0 'prefix-length x)) 18872 pl (get-text-property 0 'prefix-length x))
18656 (and re (equal (string-match (concat "\\(\\.*\\)" re) x (or pl 0)) pl) 18873 (and re (equal (string-match (concat "\\(\\.*\\)" re) x (or pl 0)) pl)
18657 (add-text-properties (or (match-end 1) (match-end 0)) (match-end 0) 18874 (add-text-properties
18658 '(face org-todo) x)) 18875 (or (match-end 1) (match-end 0)) (match-end 0)
18876 (list 'face (org-get-todo-face (match-string 2 x)))
18877 x))
18659 x))) 18878 x)))
18660 18879
18661(defsubst org-cmp-priority (a b) 18880(defsubst org-cmp-priority (a b)
@@ -19050,7 +19269,7 @@ and by additional input from the age of a schedules or deadline entry."
19050 (goto-char pos) 19269 (goto-char pos)
19051 (if (and (org-mode-p) (not (member type '("sexp")))) 19270 (if (and (org-mode-p) (not (member type '("sexp"))))
19052 (setq dbeg (progn (org-back-to-heading t) (point)) 19271 (setq dbeg (progn (org-back-to-heading t) (point))
19053 dend (org-end-of-subtree t)) 19272 dend (org-end-of-subtree t t))
19054 (setq dbeg (point-at-bol) 19273 (setq dbeg (point-at-bol)
19055 dend (min (point-max) (1+ (point-at-eol))))) 19274 dend (min (point-max) (1+ (point-at-eol)))))
19056 (goto-char dbeg) 19275 (goto-char dbeg)
@@ -19342,7 +19561,7 @@ POS defaults to point. If tags are inherited, the list contains
19342the targets in the same sequence as the headlines appear, i.e. 19561the targets in the same sequence as the headlines appear, i.e.
19343the tags of the current headline come last." 19562the tags of the current headline come last."
19344 (interactive) 19563 (interactive)
19345 (let (tags) 19564 (let (tags lastpos)
19346 (save-excursion 19565 (save-excursion
19347 (save-restriction 19566 (save-restriction
19348 (widen) 19567 (widen)
@@ -19350,7 +19569,8 @@ the tags of the current headline come last."
19350 (save-match-data 19569 (save-match-data
19351 (org-back-to-heading t) 19570 (org-back-to-heading t)
19352 (condition-case nil 19571 (condition-case nil
19353 (while t 19572 (while (not (equal lastpos (point)))
19573 (setq lastpos (point))
19354 (if (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$")) 19574 (if (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$"))
19355 (setq tags (append (org-split-string 19575 (setq tags (append (org-split-string
19356 (org-match-string-no-properties 1) ":") 19576 (org-match-string-no-properties 1) ":")
@@ -19365,28 +19585,30 @@ the tags of the current headline come last."
19365 "Set tags for the current headline." 19585 "Set tags for the current headline."
19366 (interactive) 19586 (interactive)
19367 (org-agenda-check-no-diary) 19587 (org-agenda-check-no-diary)
19368 (org-agenda-show) ;;; FIXME This is a stupid hack and should not be needed 19588 (if (and (org-region-active-p) (interactive-p))
19369 (let* ((hdmarker (or (get-text-property (point) 'org-hd-marker) 19589 (call-interactively 'org-change-tag-in-region)
19370 (org-agenda-error))) 19590 (org-agenda-show) ;;; FIXME This is a stupid hack and should not be needed
19371 (buffer (marker-buffer hdmarker)) 19591 (let* ((hdmarker (or (get-text-property (point) 'org-hd-marker)
19372 (pos (marker-position hdmarker)) 19592 (org-agenda-error)))
19373 (inhibit-read-only t) 19593 (buffer (marker-buffer hdmarker))
19374 newhead) 19594 (pos (marker-position hdmarker))
19375 (org-with-remote-undo buffer 19595 (inhibit-read-only t)
19376 (with-current-buffer buffer 19596 newhead)
19377 (widen) 19597 (org-with-remote-undo buffer
19378 (goto-char pos) 19598 (with-current-buffer buffer
19379 (save-excursion 19599 (widen)
19380 (org-show-context 'agenda)) 19600 (goto-char pos)
19381 (save-excursion 19601 (save-excursion
19382 (and (outline-next-heading) 19602 (org-show-context 'agenda))
19383 (org-flag-heading nil))) ; show the next heading 19603 (save-excursion
19384 (goto-char pos) 19604 (and (outline-next-heading)
19385 (call-interactively 'org-set-tags) 19605 (org-flag-heading nil))) ; show the next heading
19386 (end-of-line 1) 19606 (goto-char pos)
19387 (setq newhead (org-get-heading))) 19607 (call-interactively 'org-set-tags)
19388 (org-agenda-change-all-lines newhead hdmarker) 19608 (end-of-line 1)
19389 (beginning-of-line 1)))) 19609 (setq newhead (org-get-heading)))
19610 (org-agenda-change-all-lines newhead hdmarker)
19611 (beginning-of-line 1)))))
19390 19612
19391(defun org-agenda-toggle-archive-tag () 19613(defun org-agenda-toggle-archive-tag ()
19392 "Toggle the archive tag for the current entry." 19614 "Toggle the archive tag for the current entry."
@@ -19681,6 +19903,7 @@ This is a command that has to be installed in `calendar-mode-map'."
19681 "Hebrew: " (calendar-hebrew-date-string date) " (until sunset)\n" 19903 "Hebrew: " (calendar-hebrew-date-string date) " (until sunset)\n"
19682 "Islamic: " (calendar-islamic-date-string date) " (until sunset)\n" 19904 "Islamic: " (calendar-islamic-date-string date) " (until sunset)\n"
19683 "French: " (calendar-french-date-string date) "\n" 19905 "French: " (calendar-french-date-string date) "\n"
19906 "Bahai: " (calendar-bahai-date-string date) " (until sunset)\n"
19684 "Mayan: " (calendar-mayan-date-string date) "\n" 19907 "Mayan: " (calendar-mayan-date-string date) "\n"
19685 "Coptic: " (calendar-coptic-date-string date) "\n" 19908 "Coptic: " (calendar-coptic-date-string date) "\n"
19686 "Ethiopic: " (calendar-ethiopic-date-string date) "\n" 19909 "Ethiopic: " (calendar-ethiopic-date-string date) "\n"
@@ -20501,6 +20724,7 @@ translations. There is currently no way for users to extend this.")
20501 (asciip (plist-get parameters :for-ascii)) 20724 (asciip (plist-get parameters :for-ascii))
20502 (latexp (plist-get parameters :for-LaTeX)) 20725 (latexp (plist-get parameters :for-LaTeX))
20503 (commentsp (plist-get parameters :comments)) 20726 (commentsp (plist-get parameters :comments))
20727 (archived-trees (plist-get parameters :archived-trees))
20504 (inhibit-read-only t) 20728 (inhibit-read-only t)
20505 (outline-regexp "\\*+ ") 20729 (outline-regexp "\\*+ ")
20506 a b xx 20730 a b xx
@@ -20528,13 +20752,13 @@ translations. There is currently no way for users to extend this.")
20528 (insert (plist-get parameters :add-text) "\n")) 20752 (insert (plist-get parameters :add-text) "\n"))
20529 20753
20530 ;; Get rid of archived trees 20754 ;; Get rid of archived trees
20531 (when (not (eq org-export-with-archived-trees t)) 20755 (when (not (eq archived-trees t))
20532 (goto-char (point-min)) 20756 (goto-char (point-min))
20533 (while (re-search-forward re-archive nil t) 20757 (while (re-search-forward re-archive nil t)
20534 (if (not (org-on-heading-p t)) 20758 (if (not (org-on-heading-p t))
20535 (org-end-of-subtree t) 20759 (org-end-of-subtree t)
20536 (beginning-of-line 1) 20760 (beginning-of-line 1)
20537 (setq a (if org-export-with-archived-trees 20761 (setq a (if archived-trees
20538 (1+ (point-at-eol)) (point)) 20762 (1+ (point-at-eol)) (point))
20539 b (org-end-of-subtree t)) 20763 b (org-end-of-subtree t))
20540 (if (> b a) (delete-region a b))))) 20764 (if (> b a) (delete-region a b)))))
@@ -20581,7 +20805,7 @@ translations. There is currently no way for users to extend this.")
20581 '(org-protected t)) 20805 '(org-protected t))
20582 (delete-region (match-beginning 0) (match-end 0)))))) 20806 (delete-region (match-beginning 0) (match-end 0))))))
20583 20807
20584 ;; Protect quoted subtreedes 20808 ;; Protect quoted subtrees
20585 (goto-char (point-min)) 20809 (goto-char (point-min))
20586 (while (re-search-forward re-quote nil t) 20810 (while (re-search-forward re-quote nil t)
20587 (goto-char (match-beginning 0)) 20811 (goto-char (match-beginning 0))
@@ -20607,12 +20831,24 @@ translations. There is currently no way for users to extend this.")
20607 (point-at-eol)) 20831 (point-at-eol))
20608 (end-of-line 1)))) 20832 (end-of-line 1))))
20609 20833
20610 ;; Specific LaTeX cleaning 20834 ;; Specific LaTeX stuff
20611 (when latexp 20835 (when latexp
20612 (require 'org-export-latex nil t) 20836 (require 'org-export-latex nil t)
20613 (org-export-latex-cleaned-string)) 20837 (org-export-latex-cleaned-string))
20614 20838
20839 ;; Specific HTML stuff
20840 (when htmlp
20841 ;; Convert LaTeX fragments to images
20842 (when (plist-get parameters :LaTeX-fragments)
20843 (org-format-latex
20844 (concat "ltxpng/" (file-name-sans-extension
20845 (file-name-nondirectory
20846 org-current-export-file)))
20847 org-current-export-dir nil "Creating LaTeX image %s"))
20848 (message "Exporting..."))
20849
20615 ;; Remove or replace comments 20850 ;; Remove or replace comments
20851 ;; FIXME: Does LaTeX export take care of its own comments?
20616 ;; If :comments is set, use this char for commenting out comments and 20852 ;; If :comments is set, use this char for commenting out comments and
20617 ;; protect them. otherwise delete them 20853 ;; protect them. otherwise delete them
20618 (goto-char (point-min)) 20854 (goto-char (point-min))
@@ -20637,14 +20873,6 @@ translations. There is currently no way for users to extend this.")
20637 (replace-match "\\1 \\3") 20873 (replace-match "\\1 \\3")
20638 (goto-char (match-beginning 0)))) 20874 (goto-char (match-beginning 0))))
20639 20875
20640 ;; Convert LaTeX fragments to images
20641 (when (plist-get parameters :LaTeX-fragments)
20642 (org-format-latex
20643 (concat "ltxpng/" (file-name-sans-extension
20644 (file-name-nondirectory
20645 org-current-export-file)))
20646 org-current-export-dir nil "Creating LaTeX image %s"))
20647 (message "Exporting...")
20648 20876
20649 ;; Normalize links: Convert angle and plain links into bracket links 20877 ;; Normalize links: Convert angle and plain links into bracket links
20650 ;; Expand link abbreviations 20878 ;; Expand link abbreviations
@@ -20708,6 +20936,22 @@ translations. There is currently no way for users to extend this.")
20708 ;; Return the title string 20936 ;; Return the title string
20709 (org-trim (match-string 0))))))) 20937 (org-trim (match-string 0)))))))
20710 20938
20939(defun org-export-get-title-from-subtree ()
20940 "Return subtree title and exclude it from export."
20941 (let (title (m (mark)))
20942 (save-excursion
20943 (goto-char (region-beginning))
20944 (when (and (org-at-heading-p)
20945 (>= (org-end-of-subtree t t) (region-end)))
20946 ;; This is a subtree, we take the title from the first heading
20947 (goto-char (region-beginning))
20948 (looking-at org-todo-line-regexp)
20949 (setq title (match-string 3))
20950 (org-unmodified
20951 (add-text-properties (point) (1+ (point-at-eol))
20952 (list :org-license-to-kill t)))))
20953 title))
20954
20711(defun org-solidify-link-text (s &optional alist) 20955(defun org-solidify-link-text (s &optional alist)
20712 "Take link text and make a safe target out of it." 20956 "Take link text and make a safe target out of it."
20713 (save-match-data 20957 (save-match-data
@@ -20767,6 +21011,7 @@ When LEVEL is non-nil, increase section numbers on that level."
20767;;; ASCII export 21011;;; ASCII export
20768 21012
20769(defvar org-last-level nil) ; dynamically scoped variable 21013(defvar org-last-level nil) ; dynamically scoped variable
21014(defvar org-min-level nil) ; dynamically scoped variable
20770(defvar org-levels-open nil) ; dynamically scoped parameter 21015(defvar org-levels-open nil) ; dynamically scoped parameter
20771(defvar org-ascii-current-indentation nil) ; For communication 21016(defvar org-ascii-current-indentation nil) ; For communication
20772 21017
@@ -20779,6 +21024,13 @@ underlined headlines. The default is 3."
20779 (setq-default org-todo-line-regexp org-todo-line-regexp) 21024 (setq-default org-todo-line-regexp org-todo-line-regexp)
20780 (let* ((opt-plist (org-combine-plists (org-default-export-plist) 21025 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
20781 (org-infile-export-plist))) 21026 (org-infile-export-plist)))
21027 (region-p (org-region-active-p))
21028 (subtree-p
21029 (when region-p
21030 (save-excursion
21031 (goto-char (region-beginning))
21032 (and (org-at-heading-p)
21033 (>= (org-end-of-subtree t t) (region-end))))))
20782 (custom-times org-display-custom-times) 21034 (custom-times org-display-custom-times)
20783 (org-ascii-current-indentation '(0 . 0)) 21035 (org-ascii-current-indentation '(0 . 0))
20784 (level 0) line txt 21036 (level 0) line txt
@@ -20788,7 +21040,10 @@ underlined headlines. The default is 3."
20788 (filename (concat (file-name-as-directory 21040 (filename (concat (file-name-as-directory
20789 (org-export-directory :ascii opt-plist)) 21041 (org-export-directory :ascii opt-plist))
20790 (file-name-sans-extension 21042 (file-name-sans-extension
20791 (file-name-nondirectory buffer-file-name)) 21043 (or (and subtree-p
21044 (org-entry-get (region-beginning)
21045 "EXPORT_FILE_NAME" t))
21046 (file-name-nondirectory buffer-file-name)))
20792 ".txt")) 21047 ".txt"))
20793 (filename (if (equal (file-truename filename) 21048 (filename (if (equal (file-truename filename)
20794 (file-truename buffer-file-name)) 21049 (file-truename buffer-file-name))
@@ -20800,7 +21055,8 @@ underlined headlines. The default is 3."
20800 (date (format-time-string "%Y/%m/%d" (current-time))) 21055 (date (format-time-string "%Y/%m/%d" (current-time)))
20801 (time (format-time-string "%X" (org-current-time))) 21056 (time (format-time-string "%X" (org-current-time)))
20802 (author (plist-get opt-plist :author)) 21057 (author (plist-get opt-plist :author))
20803 (title (or (plist-get opt-plist :title) 21058 (title (or (and subtree-p (org-export-get-title-from-subtree))
21059 (plist-get opt-plist :title)
20804 (and (not 21060 (and (not
20805 (plist-get opt-plist :skip-before-1st-heading)) 21061 (plist-get opt-plist :skip-before-1st-heading))
20806 (org-export-grab-title-from-buffer)) 21062 (org-export-grab-title-from-buffer))
@@ -20822,6 +21078,8 @@ underlined headlines. The default is 3."
20822 :for-ascii t 21078 :for-ascii t
20823 :skip-before-1st-heading 21079 :skip-before-1st-heading
20824 (plist-get opt-plist :skip-before-1st-heading) 21080 (plist-get opt-plist :skip-before-1st-heading)
21081 :archived-trees
21082 (plist-get opt-plist :archived-trees)
20825 :add-text (plist-get opt-plist :text)) 21083 :add-text (plist-get opt-plist :text))
20826 "[\r\n]")) ;; FIXME: why \r here???/ 21084 "[\r\n]")) ;; FIXME: why \r here???/
20827 thetoc have-headings first-heading-pos 21085 thetoc have-headings first-heading-pos
@@ -20832,7 +21090,8 @@ underlined headlines. The default is 3."
20832 (remove-text-properties (point-min) (point-max) 21090 (remove-text-properties (point-min) (point-max)
20833 '(:org-license-to-kill t)))) 21091 '(:org-license-to-kill t))))
20834 21092
20835 (setq org-last-level 1) 21093 (setq org-min-level (org-get-min-level lines))
21094 (setq org-last-level org-min-level)
20836 (org-init-section-numbers) 21095 (org-init-section-numbers)
20837 21096
20838 (find-file-noselect filename) 21097 (find-file-noselect filename)
@@ -20908,7 +21167,8 @@ underlined headlines. The default is 3."
20908 (progn 21167 (progn
20909 (push 21168 (push
20910 (concat 21169 (concat
20911 (make-string (* (1- level) 4) ?\ ) 21170 (make-string
21171 (* (max 0 (- level org-min-level)) 4) ?\ )
20912 (format (if todo "%s (*)\n" "%s\n") txt)) 21172 (format (if todo "%s (*)\n" "%s\n") txt))
20913 thetoc) 21173 thetoc)
20914 (setq org-last-level level)) 21174 (setq org-last-level level))
@@ -21084,6 +21344,12 @@ command."
21084 (file buffer-file-name) 21344 (file buffer-file-name)
21085 (buffer (get-buffer-create "*Org Export Visible*")) 21345 (buffer (get-buffer-create "*Org Export Visible*"))
21086 s e) 21346 s e)
21347 ;; Need to hack the drawers here.
21348 (save-excursion
21349 (goto-char (point-min))
21350 (while (re-search-forward org-drawer-regexp nil t)
21351 (goto-char (match-beginning 1))
21352 (or (org-invisible-p) (org-flag-drawer nil))))
21087 (with-current-buffer buffer (erase-buffer)) 21353 (with-current-buffer buffer (erase-buffer))
21088 (save-excursion 21354 (save-excursion
21089 (setq s (goto-char (point-min))) 21355 (setq s (goto-char (point-min)))
@@ -21091,6 +21357,7 @@ command."
21091 (goto-char (org-find-invisible)) 21357 (goto-char (org-find-invisible))
21092 (append-to-buffer buffer s (point)) 21358 (append-to-buffer buffer s (point))
21093 (setq s (goto-char (org-find-visible)))) 21359 (setq s (goto-char (org-find-visible))))
21360 (org-cycle-hide-drawers 'all)
21094 (goto-char (point-min)) 21361 (goto-char (point-min))
21095 (unless keepp 21362 (unless keepp
21096 ;; Copy all comment lines to the end, to make sure #+ settings are 21363 ;; Copy all comment lines to the end, to make sure #+ settings are
@@ -21267,7 +21534,7 @@ This can be used in any buffer. For example, you could write an
21267itemized list in org-mode syntax in an HTML buffer and then use this 21534itemized list in org-mode syntax in an HTML buffer and then use this
21268command to convert it." 21535command to convert it."
21269 (interactive "r") 21536 (interactive "r")
21270 (let (reg html buf) 21537 (let (reg html buf pop-up-frames)
21271 (save-window-excursion 21538 (save-window-excursion
21272 (if (org-mode-p) 21539 (if (org-mode-p)
21273 (setq html (org-export-region-as-html 21540 (setq html (org-export-region-as-html
@@ -21354,6 +21621,12 @@ the body tags themselves."
21354 valid thetoc have-headings first-heading-pos 21621 valid thetoc have-headings first-heading-pos
21355 (odd org-odd-levels-only) 21622 (odd org-odd-levels-only)
21356 (region-p (org-region-active-p)) 21623 (region-p (org-region-active-p))
21624 (subtree-p
21625 (when region-p
21626 (save-excursion
21627 (goto-char (region-beginning))
21628 (and (org-at-heading-p)
21629 (>= (org-end-of-subtree t t) (region-end))))))
21357 ;; The following two are dynamically scoped into other 21630 ;; The following two are dynamically scoped into other
21358 ;; routines below. 21631 ;; routines below.
21359 (org-current-export-dir (org-export-directory :html opt-plist)) 21632 (org-current-export-dir (org-export-directory :html opt-plist))
@@ -21365,7 +21638,10 @@ the body tags themselves."
21365 (concat (file-name-as-directory 21638 (concat (file-name-as-directory
21366 (org-export-directory :html opt-plist)) 21639 (org-export-directory :html opt-plist))
21367 (file-name-sans-extension 21640 (file-name-sans-extension
21368 (file-name-nondirectory buffer-file-name)) 21641 (or (and subtree-p
21642 (org-entry-get (region-beginning)
21643 "EXPORT_FILE_NAME" t))
21644 (file-name-nondirectory buffer-file-name)))
21369 ".html"))) 21645 ".html")))
21370 (current-dir (if buffer-file-name 21646 (current-dir (if buffer-file-name
21371 (file-name-directory buffer-file-name) 21647 (file-name-directory buffer-file-name)
@@ -21379,7 +21655,8 @@ the body tags themselves."
21379 (date (format-time-string "%Y/%m/%d" (current-time))) 21655 (date (format-time-string "%Y/%m/%d" (current-time)))
21380 (time (format-time-string "%X" (org-current-time))) 21656 (time (format-time-string "%X" (org-current-time)))
21381 (author (plist-get opt-plist :author)) 21657 (author (plist-get opt-plist :author))
21382 (title (or (plist-get opt-plist :title) 21658 (title (or (and subtree-p (org-export-get-title-from-subtree))
21659 (plist-get opt-plist :title)
21383 (and (not 21660 (and (not
21384 (plist-get opt-plist :skip-before-1st-heading)) 21661 (plist-get opt-plist :skip-before-1st-heading))
21385 (org-export-grab-title-from-buffer)) 21662 (org-export-grab-title-from-buffer))
@@ -21423,6 +21700,8 @@ the body tags themselves."
21423 :for-html t 21700 :for-html t
21424 :skip-before-1st-heading 21701 :skip-before-1st-heading
21425 (plist-get opt-plist :skip-before-1st-heading) 21702 (plist-get opt-plist :skip-before-1st-heading)
21703 :archived-trees
21704 (plist-get opt-plist :archived-trees)
21426 :add-text 21705 :add-text
21427 (plist-get opt-plist :text) 21706 (plist-get opt-plist :text)
21428 :LaTeX-fragments 21707 :LaTeX-fragments
@@ -21441,7 +21720,8 @@ the body tags themselves."
21441 21720
21442 (message "Exporting...") 21721 (message "Exporting...")
21443 21722
21444 (setq org-last-level 1) 21723 (setq org-min-level (org-get-min-level lines))
21724 (setq org-last-level org-min-level)
21445 (org-init-section-numbers) 21725 (org-init-section-numbers)
21446 21726
21447 ;; Get the language-dependent settings 21727 ;; Get the language-dependent settings
@@ -21572,7 +21852,7 @@ lang=\"%s\" xml:lang=\"%s\">
21572 ))) 21852 )))
21573 line) 21853 line)
21574 lines)) 21854 lines))
21575 (while (> org-last-level 0) 21855 (while (> org-last-level (1- org-min-level))
21576 (setq org-last-level (1- org-last-level)) 21856 (setq org-last-level (1- org-last-level))
21577 (push "</li>\n</ul>\n" thetoc)) 21857 (push "</li>\n</ul>\n" thetoc))
21578 (setq thetoc (if have-headings (nreverse thetoc) nil)))) 21858 (setq thetoc (if have-headings (nreverse thetoc) nil))))
@@ -23410,11 +23690,7 @@ See the individual commands for more information."
23410 ["Next Same Level" outline-forward-same-level t] 23690 ["Next Same Level" outline-forward-same-level t]
23411 ["Previous Same Level" outline-backward-same-level t] 23691 ["Previous Same Level" outline-backward-same-level t]
23412 "--" 23692 "--"
23413 ["Jump" org-goto t] 23693 ["Jump" org-goto t])
23414 "--"
23415 ["C-a/e find headline/item start/end"
23416 (setq org-special-ctrl-a/e (not org-special-ctrl-a/e))
23417 :style toggle :selected org-special-ctrl-a/e])
23418 ("Edit Structure" 23694 ("Edit Structure"
23419 ["Move Subtree Up" org-shiftmetaup (not (org-at-table-p))] 23695 ["Move Subtree Up" org-shiftmetaup (not (org-at-table-p))]
23420 ["Move Subtree Down" org-shiftmetadown (not (org-at-table-p))] 23696 ["Move Subtree Down" org-shiftmetadown (not (org-at-table-p))]
@@ -23470,6 +23746,7 @@ See the individual commands for more information."
23470 ["Priority Down" org-shiftdown t]) 23746 ["Priority Down" org-shiftdown t])
23471 ("TAGS and Properties" 23747 ("TAGS and Properties"
23472 ["Set Tags" 'org-ctrl-c-ctrl-c (org-at-heading-p)] 23748 ["Set Tags" 'org-ctrl-c-ctrl-c (org-at-heading-p)]
23749 ["Change tag in region" 'org-change-tag-in-region (org-region-active-p)] ;FIXME
23473 ["Column view of properties" org-columns t]) 23750 ["Column view of properties" org-columns t])
23474 ("Dates and Scheduling" 23751 ("Dates and Scheduling"
23475 ["Timestamp" org-time-stamp t] 23752 ["Timestamp" org-time-stamp t]
@@ -23757,6 +24034,13 @@ return nil."
23757 (list context (match-beginning group) (match-end group)) 24034 (list context (match-beginning group) (match-end group))
23758 t))) 24035 t)))
23759 24036
24037(defun org-switch-to-buffer-other-window (&rest args)
24038 "Switch to buffer in a second window on the current frame.
24039In particular, do not allow pop-up frames."
24040 (let (pop-up-frames special-display-buffer-names special-display-regexps
24041 special-display-function)
24042 (apply 'switch-to-buffer-other-window args)))
24043
23760(defun org-combine-plists (&rest plists) 24044(defun org-combine-plists (&rest plists)
23761 "Create a single property list from all plists in PLISTS. 24045 "Create a single property list from all plists in PLISTS.
23762The process starts by copying the first list, and then setting properties 24046The process starts by copying the first list, and then setting properties
@@ -23983,14 +24267,22 @@ beyond the end of the headline."
23983 ((and (looking-at org-todo-line-regexp) 24267 ((and (looking-at org-todo-line-regexp)
23984 (= (char-after (match-end 1)) ?\ )) 24268 (= (char-after (match-end 1)) ?\ ))
23985 (goto-char 24269 (goto-char
23986 (cond ((> pos (match-beginning 3)) (match-beginning 3)) 24270 (if (eq org-special-ctrl-a/e t)
23987 ((= pos (point)) (match-beginning 3)) 24271 (cond ((> pos (match-beginning 3)) (match-beginning 3))
23988 (t (point))))) 24272 ((= pos (point)) (match-beginning 3))
24273 (t (point)))
24274 (cond ((> pos (point)) (point))
24275 ((not (eq last-command this-command)) (point))
24276 (t (match-beginning 3))))))
23989 ((org-at-item-p) 24277 ((org-at-item-p)
23990 (goto-char 24278 (goto-char
23991 (cond ((> pos (match-end 4)) (match-end 4)) 24279 (if (eq org-special-ctrl-a/e t)
23992 ((= pos (point)) (match-end 4)) 24280 (cond ((> pos (match-end 4)) (match-end 4))
23993 (t (point))))))))) 24281 ((= pos (point)) (match-end 4))
24282 (t (point)))
24283 (cond ((> pos (point)) (point))
24284 ((not (eq last-command this-command)) (point))
24285 (t (match-end 4))))))))))
23994 24286
23995(defun org-end-of-line (&optional arg) 24287(defun org-end-of-line (&optional arg)
23996 "Go to the end of the line. 24288 "Go to the end of the line.
@@ -24004,10 +24296,14 @@ beyond the end of the headline."
24004 (let ((pos (point))) 24296 (let ((pos (point)))
24005 (beginning-of-line 1) 24297 (beginning-of-line 1)
24006 (if (looking-at (org-re ".*?\\([ \t]*\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$")) 24298 (if (looking-at (org-re ".*?\\([ \t]*\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))
24007 (if (or (< pos (match-beginning 1)) 24299 (if (eq org-special-ctrl-a/e t)
24008 (= pos (match-end 0))) 24300 (if (or (< pos (match-beginning 1))
24009 (goto-char (match-beginning 1)) 24301 (= pos (match-end 0)))
24010 (goto-char (match-end 0))) 24302 (goto-char (match-beginning 1))
24303 (goto-char (match-end 0)))
24304 (if (or (< pos (match-end 0)) (not (eq this-command last-command)))
24305 (goto-char (match-end 0))
24306 (goto-char (match-beginning 1))))
24011 (end-of-line arg))))) 24307 (end-of-line arg)))))
24012 24308
24013(define-key org-mode-map "\C-a" 'org-beginning-of-line) 24309(define-key org-mode-map "\C-a" 'org-beginning-of-line)
@@ -24264,7 +24560,13 @@ Still experimental, may disappear in the furture."
24264 t))) 24560 t)))
24265 (t nil)))) ; call paragraph-fill 24561 (t nil)))) ; call paragraph-fill
24266 24562
24267 24563(defun org-get-min-level (lines)
24564 (let ((re "^\\(\\*+\\) ") l min)
24565 (catch 'exit
24566 (while (setq l (pop lines))
24567 (if (string-match re l)
24568 (throw 'exit (org-tr-level (length (match-string 1 l))))))
24569 1)))
24268 24570
24269;;;; Finish up 24571;;;; Finish up
24270 24572
diff --git a/man/ChangeLog b/man/ChangeLog
index dac0bf7570c..245b4c7e96f 100644
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -1,3 +1,7 @@
12007-08-30 Carsten Dominik <dominik@science.uva.nl>
2
3 * org.texi: Version 5.07
4
12007-08-29 Glenn Morris <rgm@gnu.org> 52007-08-29 Glenn Morris <rgm@gnu.org>
2 6
3 * emacs.texi (EMACSVER): Increase to 23.0.50. 7 * emacs.texi (EMACSVER): Increase to 23.0.50.