aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik2008-03-13 08:56:04 +0000
committerCarsten Dominik2008-03-13 08:56:04 +0000
commit2a57416ff5f4cdf77a02314eded2f38fc893c101 (patch)
treecf8fe2316a99dba9871dfabf97bbd828e6dae023
parent0fc0f17869bb4d7f8ef303d6960665a0638b6912 (diff)
downloademacs-2a57416ff5f4cdf77a02314eded2f38fc893c101.tar.gz
emacs-2a57416ff5f4cdf77a02314eded2f38fc893c101.zip
* textmodes/org.el (org-ctrl-c-star): Implement a missing branch
in the decision tree. (org-select-remember-template): Cleaned the code. (org-prepare-dblock): Added the extra :content parameter. (org-write-agenda): New output type ".ics" files. (org-write-agenda): Call `org-icalendar-verify-function', both for time stamps and for TODO entries. (org-agenda-collect-markers, org-create-marker-find-array) (org-check-agenda-marker-table): New functions. (org-agenda-marker-table): New variable. (org-export-as-html): Revert the change that killed the html buffer. Side effects first need to be studied carefully. (org-get-tags-at): Fix the structure of the condition-case statement. (org-ts-regexp0, org-repeat-re, org-display-custom-time) (org-timestamp-change): Fix regulear expressions to swallow the extra character for repeat-shift control. (org-auto-repeat-maybe): Implement the new repeater mechanisms. (org-get-legal-level): Aliased to `org-get-valid-level'. (org-dblock-write:clocktable): Added a :link parameter, linking headlines to their location in the Org agenda files. (org-get-tags-at): Bugfix: prevent `org-back-to-heading' from throwing an error when getting tags before headlines. (org-timestamp-change, org-modify-ts-extra) (org-ts-regexp1): Fix timestamp editing. (org-agenda-custom-commands-local-options): New constant. (org-agenda-custom-commands): Use `org-agenda-custom-commands-local-options' to improve customize type. "htmlize": Removed hack to fix face problem with htmlize, it no longer seem necessary. (org-follow-link-hook): New hook. (org-agenda-custom-commands): Added "Component" as a tag for each item in a command serie. (org-open-at-point): Run `org-follow-link-hook'. (org-agenda-schedule): Bugfix: don't display marker type when it is `nil'. (org-store-link): org-irc required. (org-set-regexps-and-options): Parse the new logging options. (org-extract-log-state-settings): New function. (org-todo): Handle the new ways of recording state change stuff. (org-local-logging): New function. (org-columns-open-link): Fixed bug with opening link in column view. (org-local-logging): New function (org-todo): Make sure that LOGGING properties are honoured. (org-todo-keywords): Improve docstring. (org-startup-options): Cleanup startup options. (org-set-regexps-and-options): Process the "!" markers. (org-todo): Respect the new logging stuff. (org-log-note-how): New variable. (org-add-log-maybe): New parameter HOW that defines how logging should be done and also overrides PURPOSE. Add a docstring. (org-add-log-note): Check if we really need to ask for a note. (org-get-current-options): Digest the new keyword. (org-agenda-reset-markers): Renamed from `org-agenda-maybe-reset-markers'. FORCE argument removed. (org-diary, org-agenda-quit, org-prepare-agenda): Call the renamed function, without force argument. (org-buffer-property-keys): Bind local variables s and p. (org-make-tags-matcher): Allow "" to match an empty or non-existent property value. (org-export-as-html): Join unsorted lists when they directly follow each other. Such lists may be created by headlines that are converted to lists. (org-nofm-to-completion): New function. (org-export-as-html): Use :html-extension instead of org-export-html-extension. (org-store-link): Support for links from `rmail-summary-mode'. (org-columns-new, org-complete, org-set-property): Set the `include-columns' argument in the call to `org-buffer-property-keys'. (org-buffer-property-keys): New argument `include-columns', to include properties expected by any of the COLUMS formats in the current buffer. (org-cleaned-string-for-export): Get rid of drawers first, so that they will be removed also in the text before the first headline. (org-clock-report): Show the clocktable when found. (org-refile): Fix positioning bug when `org-reverse-note-order' is nil. (org-version): With prefix argument, insert `org-version' at point. (org-agenda-goto): Recenter the window after finding the target location, to make sure the correct position will be displayed. (org-agenda-get-deadlines): Don't scale priority with the warning period. (org-insert-heading): Don't break line in the middle of the line. (org-agenda-get-deadlines): Allow `org-deadline-warning-days' to be 0. (org-update-checkbox-count): Revamped to deal with hierarchical beckboxes. This was a patch from Miguel A. Figueroa-Villanueva. (org-remove-timestamp-with-keyword): New function. (org-schedule, org-deadline): Use `org-remove-timestamp-with-keyword' to make sure all such time stamps are removed. (org-mode): Support for `align'. (org-agenda-get-deadlines): Make sure priorities increase as the due date approaches and is passed. (org-remember-apply-template): Fixed problem with tags that contain "_" or "@". (org-make-link-regexps): Improve the regular expression for plain links. (org-agenda-get-closed): List each clocking entry. (org-set-tags): Only tabify before tags if indent-tabs-mode is t. (org-special-ctrl-k): New option. (org-kill-line): New function. (org-archive-all-done): Fixed incorrect number of stars in regexp. (org-refile-get-location): New function. (org-refile-goto-last-stored): New function. (org-global-tags-completion-table): Add the value of org-tag-alist in each buffer, to make sure that also unused tags will be available for completion. (org-columns-edit-value) (org-columns-next-allowed-value): Only update if not in agenda. (org-clocktable-steps): New function. (org-dblock-write:clocktable): Call `org-clocktable-steps'. (org-archive-subtree): Add the outline tree context as a property. (org-closest-date): New optional argument `prefer'. (org-goto-auto-isearch): New option. (org-goto-map, org-get-location): Implement auto-isearch. (org-goto-local-auto-isearch-map): New variable. (org-goto-local-search-forward-headings) (org-goto-local-auto-isearch): New functions
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/textmodes/org.el2903
2 files changed, 2015 insertions, 891 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a2cf0cc6ba5..ea1a24ee8cf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12008-03-13 Carsten Dominik <dominik@science.uva.nl> 12008-03-13 Carsten Dominik <dominik@science.uva.nl>
2 2
3 * textmodes/org-export-latex.el (org-export-as-latex): Revert the
4 change that killed the LaTeX buffer.
5
3 * textmodes/org.el (org-ctrl-c-star): Implement a missing branch 6 * textmodes/org.el (org-ctrl-c-star): Implement a missing branch
4 in the decision tree. 7 in the decision tree.
5 (org-select-remember-template): Cleaned the code. 8 (org-select-remember-template): Cleaned the code.
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index a2100e78387..0aa74c37e0d 100644
--- a/lisp/textmodes/org.el
+++ b/lisp/textmodes/org.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 5.19a 8;; Version: 5.23a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -84,11 +84,17 @@
84 84
85;;; Version 85;;; Version
86 86
87(defconst org-version "5.19a" 87(defconst org-version "5.23a"
88 "The version number of the file org.el.") 88 "The version number of the file org.el.")
89(defun org-version () 89
90 (interactive) 90(defun org-version (&optional here)
91 (message "Org-mode version %s" org-version)) 91 "Show the org-mode version in the echo area.
92With prefix arg HERE, insert it at point."
93 (interactive "P")
94 (let ((version (format "Org-mode version %s" org-version)))
95 (message version)
96 (if here
97 (insert version))))
92 98
93;;; Compatibility constants 99;;; Compatibility constants
94(defconst org-xemacs-p (featurep 'xemacs)) ; not used by org.el itself 100(defconst org-xemacs-p (featurep 'xemacs)) ; not used by org.el itself
@@ -145,6 +151,34 @@
145 :group 'hypermedia 151 :group 'hypermedia
146 :group 'calendar) 152 :group 'calendar)
147 153
154(defcustom org-load-hook nil
155 "Hook that is run after org.el has been loaded."
156 :group 'org
157 :type 'hook)
158
159;(defcustom org-default-extensions '(org-irc)
160; "Extensions that should always be loaded together with org.el.
161;If the description starts with <A>, this means the extension
162;will be autoloaded when needed, preloading is not necessary.
163;FIXME: this does not ork correctly, ignore it for now."
164; :group 'org
165; :type
166; '(set :greedy t
167; (const :tag " Mouse support (org-mouse.el)" org-mouse)
168; (const :tag "<A> Publishing (org-publish.el)" org-publish)
169; (const :tag "<A> LaTeX export (org-export-latex.el)" org-export-latex)
170; (const :tag " IRC/ERC links (org-irc.el)" org-irc)
171; (const :tag " Apple Mail message links under OS X (org-mac-message.el)" org-mac-message)))
172;
173;(defun org-load-default-extensions ()
174; "Load all extensions listed in `org-default-extensions'."
175; (mapc (lambda (ext)
176; (condition-case nil (require ext)
177; (error (message "Problems while trying to load feature `%s'" ext))))
178; org-default-extensions))
179
180;(eval-after-load "org" '(org-load-default-extensions))
181
148;; FIXME: Needs a separate group... 182;; FIXME: Needs a separate group...
149(defcustom org-completion-fallback-command 'hippie-expand 183(defcustom org-completion-fallback-command 'hippie-expand
150 "The expansion command called by \\[org-complete] in normal context. 184 "The expansion command called by \\[org-complete] in normal context.
@@ -322,8 +356,7 @@ An entry can be toggled between QUOTE and normal with
322 :type 'string) 356 :type 'string)
323 357
324(defconst org-repeat-re 358(defconst org-repeat-re
325 (concat "\\(?:\\<\\(?:" org-scheduled-string "\\|" org-deadline-string "\\)" 359 "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*\\([.+]?\\+[0-9]+[dwmy]\\)"
326 " +<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*\\)\\(\\+[0-9]+[dwmy]\\)")
327 "Regular expression for specifying repeated events. 360 "Regular expression for specifying repeated events.
328After a match, group 1 contains the repeat expression.") 361After a match, group 1 contains the repeat expression.")
329 362
@@ -499,6 +532,31 @@ the values `folded', `children', or `subtree'."
499 :tag "Org Edit Structure" 532 :tag "Org Edit Structure"
500 :group 'org-structure) 533 :group 'org-structure)
501 534
535(defcustom org-odd-levels-only nil
536 "Non-nil means, skip even levels and only use odd levels for the outline.
537This has the effect that two stars are being added/taken away in
538promotion/demotion commands. It also influences how levels are
539handled by the exporters.
540Changing it requires restart of `font-lock-mode' to become effective
541for fontification also in regions already fontified.
542You may also set this on a per-file basis by adding one of the following
543lines to the buffer:
544
545 #+STARTUP: odd
546 #+STARTUP: oddeven"
547 :group 'org-edit-structure
548 :group 'org-font-lock
549 :type 'boolean)
550
551(defcustom org-adapt-indentation t
552 "Non-nil means, adapt indentation when promoting and demoting.
553When this is set and the *entire* text in an entry is indented, the
554indentation is increased by one space in a demotion command, and
555decreased by one in a promotion command. If any line in the entry
556body starts at column 0, indentation is not changed at all."
557 :group 'org-edit-structure
558 :type 'boolean)
559
502(defcustom org-special-ctrl-a/e nil 560(defcustom org-special-ctrl-a/e nil
503 "Non-nil means `C-a' and `C-e' behave specially in headlines and items. 561 "Non-nil means `C-a' and `C-e' behave specially in headlines and items.
504When t, `C-a' will bring back the cursor to the beginning of the 562When t, `C-a' will bring back the cursor to the beginning of the
@@ -521,30 +579,44 @@ to the special positions."
521(if (fboundp 'defvaralias) 579(if (fboundp 'defvaralias)
522 (defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e)) 580 (defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e))
523 581
524(defcustom org-odd-levels-only nil 582(defcustom org-special-ctrl-k nil
525 "Non-nil means, skip even levels and only use odd levels for the outline. 583 "Non-nil means `C-k' will behave specially in headlines.
526This has the effect that two stars are being added/taken away in 584When nil, `C-k' will call the default `kill-line' command.
527promotion/demotion commands. It also influences how levels are 585When t, the following will happen while the cursor is in the headline:
528handled by the exporters.
529Changing it requires restart of `font-lock-mode' to become effective
530for fontification also in regions already fontified.
531You may also set this on a per-file basis by adding one of the following
532lines to the buffer:
533 586
534 #+STARTUP: odd 587- When the cursor is at the beginning of a headline, kill the entire
535 #+STARTUP: oddeven" 588 line and possible the folded subtree below the line.
589- When in the middle of the headline text, kill the headline up to the tags.
590- When after the headline text, kill the tags."
536 :group 'org-edit-structure 591 :group 'org-edit-structure
537 :group 'org-font-lock
538 :type 'boolean) 592 :type 'boolean)
539 593
540(defcustom org-adapt-indentation t 594(defcustom org-M-RET-may-split-line '((default . t))
541 "Non-nil means, adapt indentation when promoting and demoting. 595 "Non-nil means, M-RET will split the line at the cursor position.
542When this is set and the *entire* text in an entry is indented, the 596When nil, it will go to the end of the line before making a
543indentation is increased by one space in a demotion command, and 597new line.
544decreased by one in a promotion command. If any line in the entry 598You may also set this option in a different way for different
545body starts at column 0, indentation is not changed at all." 599contexts. Valid contexts are:
546 :group 'org-edit-structure 600
547 :type 'boolean) 601headline when creating a new headline
602item when creating a new item
603table in a table field
604default the value to be used for all contexts not explicitly
605 customized"
606 :group 'org-structure
607 :group 'org-table
608 :type '(choice
609 (const :tag "Always" t)
610 (const :tag "Never" nil)
611 (repeat :greedy t :tag "Individual contexts"
612 (cons
613 (choice :tag "Context"
614 (const headline)
615 (const item)
616 (const table)
617 (const default))
618 (boolean)))))
619
548 620
549(defcustom org-blank-before-new-entry '((heading . nil) 621(defcustom org-blank-before-new-entry '((heading . nil)
550 (plain-list-item . nil)) 622 (plain-list-item . nil))
@@ -569,6 +641,11 @@ See also the QUOTE keyword."
569 :group 'org-edit-structure 641 :group 'org-edit-structure
570 :type 'boolean) 642 :type 'boolean)
571 643
644(defcustom org-goto-auto-isearch t
645 "Non-nil means, typing characters in org-goto starts incremental search."
646 :group 'org-edit-structure
647 :type 'boolean)
648
572(defgroup org-sparse-trees nil 649(defgroup org-sparse-trees nil
573 "Options concerning sparse trees in Org-mode." 650 "Options concerning sparse trees in Org-mode."
574 :tag "Org Sparse Trees" 651 :tag "Org Sparse Trees"
@@ -733,7 +810,7 @@ This variable is obsolete and has no effect anymore, instead add ot remove
733 :group 'org-archive 810 :group 'org-archive
734 :type 'boolean) 811 :type 'boolean)
735 812
736(defcustom org-archive-save-context-info '(time file category todo itags) 813(defcustom org-archive-save-context-info '(time file olpath category todo itags)
737 "Parts of context info that should be stored as properties when archiving. 814 "Parts of context info that should be stored as properties when archiving.
738When a subtree is moved to an archive file, it looses information given by 815When a subtree is moved to an archive file, it looses information given by
739context, like inherited tags, the category, and possibly also the TODO 816context, like inherited tags, the category, and possibly also the TODO
@@ -746,6 +823,8 @@ itags The local tags, in the headline of the subtree.
746ltags The tags the subtree inherits from further up the hierarchy. 823ltags The tags the subtree inherits from further up the hierarchy.
747todo The pre-archive TODO state. 824todo The pre-archive TODO state.
748category The category, taken from file name or #+CATEGORY lines. 825category The category, taken from file name or #+CATEGORY lines.
826olpath The outline path to the item. These are all headlines above
827 the current item, separated by /, like a file path.
749 828
750For each symbol present in the list, a property will be created in 829For each symbol present in the list, a property will be created in
751the archived entry, with a prefix \"PRE_ARCHIVE_\", to remember this 830the archived entry, with a prefix \"PRE_ARCHIVE_\", to remember this
@@ -758,6 +837,7 @@ information."
758 (const :tag "TODO state" todo) 837 (const :tag "TODO state" todo)
759 (const :tag "TODO state" priority) 838 (const :tag "TODO state" priority)
760 (const :tag "Inherited tags" itags) 839 (const :tag "Inherited tags" itags)
840 (const :tag "Outline path" olpath)
761 (const :tag "Local tags" ltags))) 841 (const :tag "Local tags" ltags)))
762 842
763(defgroup org-imenu-and-speedbar nil 843(defgroup org-imenu-and-speedbar nil
@@ -1087,10 +1167,9 @@ Changing this variable requires a restart of Emacs to become effective."
1087 :group 'org-link 1167 :group 'org-link
1088 :type '(set (const :tag "Double bracket links (new style)" bracket) 1168 :type '(set (const :tag "Double bracket links (new style)" bracket)
1089 (const :tag "Angular bracket links (old style)" angular) 1169 (const :tag "Angular bracket links (old style)" angular)
1090 (const :tag "plain text links" plain) 1170 (const :tag "Plain text links" plain)
1091 (const :tag "Radio target matches" radio) 1171 (const :tag "Radio target matches" radio)
1092 (const :tag "Tags" tag) 1172 (const :tag "Tags" tag)
1093 (const :tag "Tags" target)
1094 (const :tag "Timestamps" date))) 1173 (const :tag "Timestamps" date)))
1095 1174
1096(defgroup org-link-store nil 1175(defgroup org-link-store nil
@@ -1166,6 +1245,11 @@ negates this setting for the duration of the command."
1166 :tag "Org Follow Link" 1245 :tag "Org Follow Link"
1167 :group 'org-link) 1246 :group 'org-link)
1168 1247
1248(defcustom org-follow-link-hook nil
1249 "Hook that is run after a link has been followed."
1250 :group 'org-link-follow
1251 :type 'hook)
1252
1169(defcustom org-tab-follows-link nil 1253(defcustom org-tab-follows-link nil
1170 "Non-nil means, on links TAB will follow the link. 1254 "Non-nil means, on links TAB will follow the link.
1171Needs to be set before org.el is loaded." 1255Needs to be set before org.el is loaded."
@@ -1178,9 +1262,10 @@ Needs to be set before org.el is loaded."
1178 :group 'org-link-follow 1262 :group 'org-link-follow
1179 :type 'boolean) 1263 :type 'boolean)
1180 1264
1181(defcustom org-mouse-1-follows-link t 1265(defcustom org-mouse-1-follows-link
1266 (if (boundp 'mouse-1-click-follows-link) mouse-1-click-follows-link t)
1182 "Non-nil means, mouse-1 on a link will follow the link. 1267 "Non-nil means, mouse-1 on a link will follow the link.
1183A longer mouse click will still set point. Does not wortk on XEmacs. 1268A longer mouse click will still set point. Does not work on XEmacs.
1184Needs to be set before org.el is loaded." 1269Needs to be set before org.el is loaded."
1185 :group 'org-link-follow 1270 :group 'org-link-follow
1186 :type 'boolean) 1271 :type 'boolean)
@@ -1411,13 +1496,36 @@ When this variable is nil, `C-c C-c' give you the prompts, and
1411 :group 'org-remember 1496 :group 'org-remember
1412 :type 'boolean) 1497 :type 'boolean)
1413 1498
1414(defcustom org-remember-use-refile-when-interactive t 1499(defcustom org-remember-interactive-interface 'refile
1415 "Non-nil means, use refile to file a remember note. 1500 "The interface to be used for interactive filing of remember notes.
1416This is only used when the interactive mode for selecting a filing 1501This is only used when the interactive mode for selecting a filing
1417location is used (see the variable `org-remember-store-without-prompt'). 1502location is used (see the variable `org-remember-store-without-prompt').
1418When nil, the `org-goto' interface is used." 1503Allowed vaues are:
1504outline The interface shows an outline of the relevant file
1505 and the correct heading is found by moving through
1506 the outline or by searching with incremental search.
1507outline-path-completion Headlines in the current buffer are offered via
1508 completion.
1509refile Use the refile interface, and offer headlines,
1510 possibly from different buffers."
1419 :group 'org-remember 1511 :group 'org-remember
1420 :type 'boolean) 1512 :type '(choice
1513 (const :tag "Refile" refile)
1514 (const :tag "Outline" outline)
1515 (const :tag "Outline-path-completion" outline-path-completion)))
1516
1517(defcustom org-goto-interface 'outline
1518 "The default interface to be used for `org-goto'.
1519Allowed vaues are:
1520outline The interface shows an outline of the relevant file
1521 and the correct heading is found by moving through
1522 the outline or by searching with incremental search.
1523outline-path-completion Headlines in the current buffer are offered via
1524 completion."
1525 :group 'org-remember ; FIXME: different group for org-goto and org-refile
1526 :type '(choice
1527 (const :tag "Outline" outline)
1528 (const :tag "Outline-path-completion" outline-path-completion)))
1421 1529
1422(defcustom org-remember-default-headline "" 1530(defcustom org-remember-default-headline ""
1423 "The headline that should be the default location in the notes file. 1531 "The headline that should be the default location in the notes file.
@@ -1440,6 +1548,12 @@ element can specify the headline in that file that should be offered
1440first when the user is asked to file the entry. The default headline is 1548first when the user is asked to file the entry. The default headline is
1441given in the variable `org-remember-default-headline'. 1549given in the variable `org-remember-default-headline'.
1442 1550
1551An optional sixth element specifies the contexts in which the user can
1552select the template. This element can be either a list of major modes
1553or a function. `org-remember' will first check whether the function
1554returns `t' or if we are in any of the listed major mode, and select
1555the template accordingly.
1556
1443The template specifies the structure of the remember buffer. It should have 1557The template specifies the structure of the remember buffer. It should have
1444a first line starting with a star, to act as the org-mode headline. 1558a first line starting with a star, to act as the org-mode headline.
1445Furthermore, the following %-escapes will be replaced with content: 1559Furthermore, the following %-escapes will be replaced with content:
@@ -1454,9 +1568,8 @@ Furthermore, the following %-escapes will be replaced with content:
1454 You may define a prompt like %^{Please specify birthday}t 1568 You may define a prompt like %^{Please specify birthday}t
1455 %n user name (taken from `user-full-name') 1569 %n user name (taken from `user-full-name')
1456 %a annotation, normally the link created with org-store-link 1570 %a annotation, normally the link created with org-store-link
1457 %i initial content, the region when remember is called with C-u. 1571 %i initial content, the region active. If %i is indented,
1458 If %i is indented, the entire inserted text will be indented 1572 the entire inserted text will be indented as well.
1459 as well.
1460 %c content of the clipboard, or current kill ring head 1573 %c content of the clipboard, or current kill ring head
1461 %^g prompt for tags, with completion on tags in target file 1574 %^g prompt for tags, with completion on tags in target file
1462 %^G prompt for tags, with completion all tags in all agenda files 1575 %^G prompt for tags, with completion all tags in all agenda files
@@ -1485,7 +1598,7 @@ w3, w3m | %:type %:url
1485info | %:type %:file %:node 1598info | %:type %:file %:node
1486calendar | %:type %:date" 1599calendar | %:type %:date"
1487 :group 'org-remember 1600 :group 'org-remember
1488 :get (lambda (var) ; Make sure all entries have 5 elements 1601 :get (lambda (var) ; Make sure all entries have at least 5 elements
1489 (mapcar (lambda (x) 1602 (mapcar (lambda (x)
1490 (if (not (stringp (car x))) (setq x (cons "" x))) 1603 (if (not (stringp (car x))) (setq x (cons "" x)))
1491 (cond ((= (length x) 4) (append x '(""))) 1604 (cond ((= (length x) 4) (append x '("")))
@@ -1494,7 +1607,7 @@ calendar | %:type %:date"
1494 (default-value var))) 1607 (default-value var)))
1495 :type '(repeat 1608 :type '(repeat
1496 :tag "enabled" 1609 :tag "enabled"
1497 (list :value ("" ?a "\n" nil nil) 1610 (list :value ("" ?a "\n" nil nil nil)
1498 (string :tag "Name") 1611 (string :tag "Name")
1499 (character :tag "Selection Key") 1612 (character :tag "Selection Key")
1500 (string :tag "Template") 1613 (string :tag "Template")
@@ -1503,7 +1616,13 @@ calendar | %:type %:date"
1503 (const :tag "Prompt for file" nil)) 1616 (const :tag "Prompt for file" nil))
1504 (choice 1617 (choice
1505 (string :tag "Destination headline") 1618 (string :tag "Destination headline")
1506 (const :tag "Selection interface for heading"))))) 1619 (const :tag "Selection interface for heading"))
1620 (choice
1621 (const :tag "Use by default" nil)
1622 (const :tag "Use in all contexts" t)
1623 (repeat :tag "Use only if in major mode"
1624 (symbol :tag "Major mode"))
1625 (function :tag "Perform a check against function")))))
1507 1626
1508(defcustom org-reverse-note-order nil 1627(defcustom org-reverse-note-order nil
1509 "Non-nil means, store new notes at the beginning of a file or entry. 1628 "Non-nil means, store new notes at the beginning of a file or entry.
@@ -1592,6 +1711,23 @@ cycling, see the manual.
1592TODO keywords and interpretation can also be set on a per-file basis with 1711TODO keywords and interpretation can also be set on a per-file basis with
1593the special #+SEQ_TODO and #+TYP_TODO lines. 1712the special #+SEQ_TODO and #+TYP_TODO lines.
1594 1713
1714Each keyword can optionally specify a character for fast state selection
1715\(in combination with the variable `org-use-fast-todo-selection')
1716and specifiers for state change logging, using the same syntax
1717that is used in the \"#+TODO:\" lines. For example, \"WAIT(w)\" says
1718that the WAIT state can be selected with the \"w\" key. \"WAIT(w!)\"
1719indicates to record a time stamp each time this state is selected.
1720
1721Each keyword may also specify if a timestamp or a note should be
1722recorded when entering or leaving the state, by adding additional
1723characters in the parenthesis after the keyword. This looks like this:
1724\"WAIT(w@/!)\". \"@\" means to add a note (with time), \"!\" means to
1725record only the time of the state change. With X and Y being either
1726\"@\" or \"!\", \"X/Y\" means use X when entering the state, and use
1727Y when leaving the state if and only if the *target* state does not
1728define X. You may omit any of the fast-selection key or X or /Y,
1729so WAIT(w@), WAIT(w/@) and WAIT(@/@) are all valid.
1730
1595For backward compatibility, this variable may also be just a list 1731For backward compatibility, this variable may also be just a list
1596of keywords - in this case the interptetation (sequence or type) will be 1732of keywords - in this case the interptetation (sequence or type) will be
1597taken from the (otherwise obsolete) variable `org-todo-interpretation'." 1733taken from the (otherwise obsolete) variable `org-todo-interpretation'."
@@ -1609,7 +1745,8 @@ taken from the (otherwise obsolete) variable `org-todo-interpretation'."
1609 (repeat 1745 (repeat
1610 (string :tag "Keyword")))))) 1746 (string :tag "Keyword"))))))
1611 1747
1612(defvar org-todo-keywords-1 nil) 1748(defvar org-todo-keywords-1 nil
1749 "All TODO and DONE keywords active in a buffer.")
1613(make-variable-buffer-local 'org-todo-keywords-1) 1750(make-variable-buffer-local 'org-todo-keywords-1)
1614(defvar org-todo-keywords-for-agenda nil) 1751(defvar org-todo-keywords-for-agenda nil)
1615(defvar org-done-keywords-for-agenda nil) 1752(defvar org-done-keywords-for-agenda nil)
@@ -1673,46 +1810,38 @@ Lisp variable `state'."
1673 :type 'hook) 1810 :type 'hook)
1674 1811
1675(defcustom org-log-done nil 1812(defcustom org-log-done nil
1676 "When set, insert a (non-active) time stamp when TODO entry is marked DONE. 1813 "Non-nil means, record a CLOSED timestamp when moving an entry to DONE.
1677When the state of an entry is changed from nothing or a DONE state to 1814When equal to the list (done), also prompt for a closing note.
1678a not-done TODO state, remove a previous closing date. 1815This can also be configured on a per-file basis by adding one of
1679
1680This can also be a list of symbols indicating under which conditions
1681the time stamp recording the action should be annotated with a short note.
1682Valid members of this list are
1683
1684 done Offer to record a note when marking entries done
1685 state Offer to record a note whenever changing the TODO state
1686 of an item. This is only relevant if TODO keywords are
1687 interpreted as sequence, see variable `org-todo-interpretation'.
1688 When `state' is set, this includes tracking `done'.
1689 clock-out Offer to record a note when clocking out of an item.
1690
1691A separate window will then pop up and allow you to type a note.
1692After finishing with C-c C-c, the note will be added directly after the
1693timestamp, as a plain list item. See also the variable
1694`org-log-note-headings'.
1695
1696Logging can also be configured on a per-file basis by adding one of
1697the following lines anywhere in the buffer: 1816the following lines anywhere in the buffer:
1698 1817
1699 #+STARTUP: logdone 1818 #+STARTUP: logdone
1700 #+STARTUP: nologging
1701 #+STARTUP: lognotedone 1819 #+STARTUP: lognotedone
1702 #+STARTUP: lognotestate 1820 #+STARTUP: nologdone"
1703 #+STARTUP: lognoteclock-out
1704
1705You can have local logging settings for a subtree by setting the LOGGING
1706property to one or more of these keywords."
1707 :group 'org-todo 1821 :group 'org-todo
1708 :group 'org-progress 1822 :group 'org-progress
1709 :type '(choice 1823 :type '(choice
1710 (const :tag "off" nil) 1824 (const :tag "No logging" nil)
1711 (const :tag "on" t) 1825 (const :tag "Record CLOSED timestamp" time)
1712 (set :tag "on, with notes, detailed control" :greedy t :value (done) 1826 (const :tag "Record CLOSED timestamp with closing note." note)))
1713 (const :tag "when item is marked DONE" done) 1827
1714 (const :tag "when TODO state changes" state) 1828;; Normalize old uses of org-log-done.
1715 (const :tag "when clocking out" clock-out)))) 1829(cond
1830 ((eq org-log-done t) (setq org-log-done 'time))
1831 ((and (listp org-log-done) (memq 'done org-log-done))
1832 (setq org-log-done 'note)))
1833
1834;; FIXME: document
1835(defcustom org-log-note-clock-out nil
1836 "Non-nil means, recored a note when clocking out of an item.
1837This can also be configured on a per-file basis by adding one of
1838the following lines anywhere in the buffer:
1839
1840 #+STARTUP: lognoteclock-out
1841 #+STARTUP: nolognoteclock-out"
1842 :group 'org-todo
1843 :group 'org-progress
1844 :type 'boolean)
1716 1845
1717(defcustom org-log-done-with-time t 1846(defcustom org-log-done-with-time t
1718 "Non-nil means, the CLOSED time stamp will contain date and time. 1847 "Non-nil means, the CLOSED time stamp will contain date and time.
@@ -1748,19 +1877,32 @@ When nil, the notes will be orderer according to time."
1748 :group 'org-progress 1877 :group 'org-progress
1749 :type 'boolean) 1878 :type 'boolean)
1750 1879
1751(defcustom org-log-repeat t 1880(defcustom org-log-repeat 'time
1752 "Non-nil means, prompt for a note when REPEAT is resetting a TODO entry. 1881 "Non-nil means, record moving through the DONE state when triggering repeat.
1753When nil, no note will be taken. 1882An auto-repeating tasks is immediately switched back to TODO when marked
1883done. If you are not logging state changes (by adding \"@\" or \"!\" to
1884the TODO keyword definition, or recording a cloing note by setting
1885`org-log-done', there will be no record of the task moving trhough DONE.
1886This variable forces taking a note anyway. Possible values are:
1887
1888nil Don't force a record
1889time Record a time stamp
1890note Record a note
1891
1754This option can also be set with on a per-file-basis with 1892This option can also be set with on a per-file-basis with
1755 1893
1756 #+STARTUP: logrepeat 1894 #+STARTUP: logrepeat
1895 #+STARTUP: lognoterepeat
1757 #+STARTUP: nologrepeat 1896 #+STARTUP: nologrepeat
1758 1897
1759You can have local logging settings for a subtree by setting the LOGGING 1898You can have local logging settings for a subtree by setting the LOGGING
1760property to one or more of these keywords." 1899property to one or more of these keywords."
1761 :group 'org-todo 1900 :group 'org-todo
1762 :group 'org-progress 1901 :group 'org-progress
1763 :type 'boolean) 1902 :type '(choice
1903 (const :tag "Don't force a record" nil)
1904 (const :tag "Force recording the DONE state" time)
1905 (const :tag "Force recording a note with the DONE state" note)))
1764 1906
1765(defcustom org-clock-into-drawer 2 1907(defcustom org-clock-into-drawer 2
1766 "Should clocking info be wrapped into a drawer? 1908 "Should clocking info be wrapped into a drawer?
@@ -1839,14 +1981,34 @@ the time stamp will always be forced into the second line."
1839 "Formats for `format-time-string' which are used for time stamps. 1981 "Formats for `format-time-string' which are used for time stamps.
1840It is not recommended to change this constant.") 1982It is not recommended to change this constant.")
1841 1983
1842(defcustom org-time-stamp-rounding-minutes 0 1984(defcustom org-time-stamp-rounding-minutes '(0 5)
1843 "Number of minutes to round time stamps to upon insertion. 1985 "Number of minutes to round time stamps to.
1844When zero, insert the time unmodified. Useful rounding numbers 1986These are two values, the first applies when first creating a time stamp.
1845should be factors of 60, so for example 5, 10, 15. 1987The second applies when changing it with the commands `S-up' and `S-down'.
1846When this is not zero, you can still force an exact time-stamp by using 1988When changing the time stamp, this means that it will change in steps
1847a double prefix argument to a time-stamp command like `C-c .' or `C-c !'." 1989of N minues, as given by the second value.
1990
1991When a setting is 0 or 1, insert the time unmodified. Useful rounding
1992numbers should be factors of 60, so for example 5, 10, 15.
1993
1994When this is larger than 1, you can still force an exact time-stamp by using
1995a double prefix argument to a time-stamp command like `C-c .' or `C-c !',
1996and by using a prefix arg to `S-up/down' to specify the exact number
1997of minutes to shift."
1848 :group 'org-time 1998 :group 'org-time
1849 :type 'integer) 1999 :get '(lambda (var) ; Make sure all entries have 5 elements
2000 (if (integerp (default-value var))
2001 (list (default-value var) 5)
2002 (default-value var)))
2003 :type '(list
2004 (integer :tag "when inserting times")
2005 (integer :tag "when modifying times")))
2006
2007;; Make sure old customizations of this variable don't lead to problems.
2008(when (integerp org-time-stamp-rounding-minutes)
2009 (setq org-time-stamp-rounding-minutes
2010 (list org-time-stamp-rounding-minutes
2011 org-time-stamp-rounding-minutes)))
1850 2012
1851(defcustom org-display-custom-times nil 2013(defcustom org-display-custom-times nil
1852 "Non-nil means, overlay custom formats over all time stamps. 2014 "Non-nil means, overlay custom formats over all time stamps.
@@ -2145,12 +2307,21 @@ Nil means to remove them, after a query, from the list."
2145 :group 'org-agenda 2307 :group 'org-agenda
2146 :type 'boolean) 2308 :type 'boolean)
2147 2309
2148(defcustom org-agenda-multi-occur-extra-files nil 2310(defcustom org-agenda-text-search-extra-files nil
2149 "List of extra files to be searched by `org-occur-in-agenda-files'. 2311 "List of extra files to be searched by text search commands.
2150The files in `org-agenda-files' are always searched." 2312These files will be search in addition to the agenda files bu the
2313commands `org-search-view' (`C-c a s') and `org-occur-in-agenda-files'.
2314Note that these files will only be searched for text search commands,
2315not for the other agenda views like todo lists, tag earches or the weekly
2316agenda. This variable is intended to list notes and possibly archive files
2317that should also be searched by these two commands."
2151 :group 'org-agenda 2318 :group 'org-agenda
2152 :type '(repeat file)) 2319 :type '(repeat file))
2153 2320
2321(if (fboundp 'defvaralias)
2322 (defvaralias 'org-agenda-multi-occur-extra-files
2323 'org-agenda-text-search-extra-files))
2324
2154(defcustom org-agenda-confirm-kill 1 2325(defcustom org-agenda-confirm-kill 1
2155 "When set, remote killing from the agenda buffer needs confirmation. 2326 "When set, remote killing from the agenda buffer needs confirmation.
2156When t, a confirmation is always needed. When a number N, confirmation is 2327When t, a confirmation is always needed. When a number N, confirmation is
@@ -2211,7 +2382,7 @@ the fonts used by the agenda, here is an example:
2211 font-weight: 600; 2382 font-weight: 600;
2212 } 2383 }
2213 .org-todo { 2384 .org-todo {
2214 color: #cc6666;Week-agenda: 2385 color: #cc6666;
2215 font-weight: bold; 2386 font-weight: bold;
2216 } 2387 }
2217 .org-done { 2388 .org-done {
@@ -2238,41 +2409,121 @@ you can \"misuse\" it to also add other text to the header. However,
2238 :tag "Org Agenda Custom Commands" 2409 :tag "Org Agenda Custom Commands"
2239 :group 'org-agenda) 2410 :group 'org-agenda)
2240 2411
2412(defconst org-sorting-choice
2413 '(choice
2414 (const time-up) (const time-down)
2415 (const category-keep) (const category-up) (const category-down)
2416 (const tag-down) (const tag-up)
2417 (const priority-up) (const priority-down))
2418 "Sorting choices.")
2419
2420(defconst org-agenda-custom-commands-local-options
2421 `(repeat :tag "Local settings for this command. Remember to quote values"
2422 (choice :tag "Setting"
2423 (list :tag "Any variable"
2424 (variable :tag "Variable")
2425 (sexp :tag "Value"))
2426 (list :tag "Files to be searched"
2427 (const org-agenda-files)
2428 (list
2429 (const :format "" quote)
2430 (repeat
2431 (file))))
2432 (list :tag "Sorting strategy"
2433 (const org-agenda-sorting-strategy)
2434 (list
2435 (const :format "" quote)
2436 (repeat
2437 ,org-sorting-choice)))
2438 (list :tag "Prefix format"
2439 (const org-agenda-prefix-format :value " %-12:c%?-12t% s")
2440 (string))
2441 (list :tag "Number of days in agenda"
2442 (const org-agenda-ndays)
2443 (integer :value 1))
2444 (list :tag "Fixed starting date"
2445 (const org-agenda-start-day)
2446 (string :value "2007-11-01"))
2447 (list :tag "Start on day of week"
2448 (const org-agenda-start-on-weekday)
2449 (choice :value 1
2450 (const :tag "Today" nil)
2451 (number :tag "Weekday No.")))
2452 (list :tag "Include data from diary"
2453 (const org-agenda-include-diary)
2454 (boolean))
2455 (list :tag "Deadline Warning days"
2456 (const org-deadline-warning-days)
2457 (integer :value 1))
2458 (list :tag "Standard skipping condition"
2459 :value (org-agenda-skip-function '(org-agenda-skip-entry-if))
2460 (const org-agenda-skip-function)
2461 (list
2462 (const :format "" quote)
2463 (list
2464 (choice
2465 :tag "Skiping range"
2466 (const :tag "Skip entry" org-agenda-skip-entry-if)
2467 (const :tag "Skip subtree" org-agenda-skip-subtree-if))
2468 (repeat :inline t :tag "Conditions for skipping"
2469 (choice
2470 :tag "Condition type"
2471 (list :tag "Regexp matches" :inline t (const :format "" 'regexp) (regexp))
2472 (list :tag "Regexp does not match" :inline t (const :format "" 'notregexp) (regexp))
2473 (const :tag "scheduled" 'scheduled)
2474 (const :tag "not scheduled" 'notscheduled)
2475 (const :tag "deadline" 'deadline)
2476 (const :tag "no deadline" 'notdeadline))))))
2477 (list :tag "Non-standard skipping condition"
2478 :value (org-agenda-skip-function)
2479 (list
2480 (const org-agenda-skip-function)
2481 (sexp :tag "Function or form (quoted!)")))))
2482 "Selection of examples for agenda command settings.
2483This will be spliced into the custom type of
2484`org-agenda-custom-commands'.")
2485
2486
2241(defcustom org-agenda-custom-commands nil 2487(defcustom org-agenda-custom-commands nil
2242 "Custom commands for the agenda. 2488 "Custom commands for the agenda.
2243These commands will be offered on the splash screen displayed by the 2489These commands will be offered on the splash screen displayed by the
2244agenda dispatcher \\[org-agenda]. Each entry is a list like this: 2490agenda dispatcher \\[org-agenda]. Each entry is a list like this:
2245 2491
2246 (key desc type match options files) 2492 (key desc type match settings files)
2247 2493
2248key The key (one or more characters as a string) to be associated 2494key The key (one or more characters as a string) to be associated
2249 with the command. 2495 with the command.
2250desc A description of the commend, when omitted or nil, a default 2496desc A description of the command, when omitted or nil, a default
2251 description is built using MATCH. 2497 description is built using MATCH.
2252type The command type, any of the following symbols: 2498type The command type, any of the following symbols:
2253 todo Entries with a specific TODO keyword, in all agenda files. 2499 agenda The daily/weekly agenda.
2254 tags Tags match in all agenda files. 2500 todo Entries with a specific TODO keyword, in all agenda files.
2255 tags-todo Tags match in all agenda files, TODO entries only. 2501 search Entries containing search words entry or headline.
2256 todo-tree Sparse tree of specific TODO keyword in *current* file. 2502 tags Tags/Property/TODO match in all agenda files.
2257 tags-tree Sparse tree with all tags matches in *current* file. 2503 tags-todo Tags/P/T match in all agenda files, TODO entries only.
2258 occur-tree Occur sparse tree for *current* file. 2504 todo-tree Sparse tree of specific TODO keyword in *current* file.
2259 ... A user-defined function. 2505 tags-tree Sparse tree with all tags matches in *current* file.
2260match What to search for: 2506 occur-tree Occur sparse tree for *current* file.
2261 - a single keyword for TODO keyword searches 2507 ... A user-defined function.
2262 - a tags match expression for tags searches 2508match What to search for:
2263 - a regular expression for occur searches 2509 - a single keyword for TODO keyword searches
2264options A list of option settings, similar to that in a let form, so like 2510 - a tags match expression for tags searches
2265 this: ((opt1 val1) (opt2 val2) ...) 2511 - a word search expression for text searches.
2266files A list of files file to write the produced agenda buffer to 2512 - a regular expression for occur searches
2267 with the command `org-store-agenda-views'. 2513 For all other commands, this should be the empty string.
2268 If a file name ends in \".html\", an HTML version of the buffer 2514settings A list of option settings, similar to that in a let form, so like
2269 is written out. If it ends in \".ps\", a postscript version is 2515 this: ((opt1 val1) (opt2 val2) ...). The values will be
2270 produced. Otherwide, only the plain text is written to the file. 2516 evaluated at the moment of execution, so quote them when needed.
2517files A list of files file to write the produced agenda buffer to
2518 with the command `org-store-agenda-views'.
2519 If a file name ends in \".html\", an HTML version of the buffer
2520 is written out. If it ends in \".ps\", a postscript version is
2521 produced. Otherwide, only the plain text is written to the file.
2271 2522
2272You can also define a set of commands, to create a composite agenda buffer. 2523You can also define a set of commands, to create a composite agenda buffer.
2273In this case, an entry looks like this: 2524In this case, an entry looks like this:
2274 2525
2275 (key desc (cmd1 cmd2 ...) general-options file) 2526 (key desc (cmd1 cmd2 ...) general-settings-for-whole-set files)
2276 2527
2277where 2528where
2278 2529
@@ -2280,12 +2531,13 @@ desc A description string to be displayed in the dispatcher menu.
2280cmd An agenda command, similar to the above. However, tree commands 2531cmd An agenda command, similar to the above. However, tree commands
2281 are no allowed, but instead you can get agenda and global todo list. 2532 are no allowed, but instead you can get agenda and global todo list.
2282 So valid commands for a set are: 2533 So valid commands for a set are:
2283 (agenda) 2534 (agenda \"\" settings)
2284 (alltodo) 2535 (alltodo \"\" settings)
2285 (stuck) 2536 (stuck \"\" settings)
2286 (todo \"match\" options files) 2537 (todo \"match\" settings files)
2287 (tags \"match\" options files) 2538 (search \"match\" settings files)
2288 (tags-todo \"match\" options files) 2539 (tags \"match\" settings files)
2540 (tags-todo \"match\" settings files)
2289 2541
2290Each command can carry a list of options, and another set of options can be 2542Each command can carry a list of options, and another set of options can be
2291given for the whole set of commands. Individual command options take 2543given for the whole set of commands. Individual command options take
@@ -2301,14 +2553,15 @@ should provide a description for the prefix, like
2301 (\"hp\" tags \"+HOME+Peter\") 2553 (\"hp\" tags \"+HOME+Peter\")
2302 (\"hk\" tags \"+HOME+Kim\")))" 2554 (\"hk\" tags \"+HOME+Kim\")))"
2303 :group 'org-agenda-custom-commands 2555 :group 'org-agenda-custom-commands
2304 :type '(repeat 2556 :type `(repeat
2305 (choice :value ("a" "" tags "" nil) 2557 (choice :value ("x" "Describe command here" tags "" nil)
2306 (list :tag "Single command" 2558 (list :tag "Single command"
2307 (string :tag "Access Key(s) ") 2559 (string :tag "Access Key(s) ")
2308 (option (string :tag "Description")) 2560 (option (string :tag "Description"))
2309 (choice 2561 (choice
2310 (const :tag "Agenda" agenda) 2562 (const :tag "Agenda" agenda)
2311 (const :tag "TODO list" alltodo) 2563 (const :tag "TODO list" alltodo)
2564 (const :tag "Search words" search)
2312 (const :tag "Stuck projects" stuck) 2565 (const :tag "Stuck projects" stuck)
2313 (const :tag "Tags search (all agenda files)" tags) 2566 (const :tag "Tags search (all agenda files)" tags)
2314 (const :tag "Tags search of TODO entries (all agenda files)" tags-todo) 2567 (const :tag "Tags search of TODO entries (all agenda files)" tags-todo)
@@ -2317,54 +2570,62 @@ should provide a description for the prefix, like
2317 (const :tag "TODO keyword tree (current buffer)" todo-tree) 2570 (const :tag "TODO keyword tree (current buffer)" todo-tree)
2318 (const :tag "Occur tree (current buffer)" occur-tree) 2571 (const :tag "Occur tree (current buffer)" occur-tree)
2319 (sexp :tag "Other, user-defined function")) 2572 (sexp :tag "Other, user-defined function"))
2320 (string :tag "Match") 2573 (string :tag "Match (only for some commands)")
2321 (repeat :tag "Local options" 2574 ,org-agenda-custom-commands-local-options
2322 (list (variable :tag "Option") (sexp :tag "Value")))
2323 (option (repeat :tag "Export" (file :tag "Export to")))) 2575 (option (repeat :tag "Export" (file :tag "Export to"))))
2324 (list :tag "Command series, all agenda files" 2576 (list :tag "Command series, all agenda files"
2325 (string :tag "Access Key(s)") 2577 (string :tag "Access Key(s)")
2326 (string :tag "Description ") 2578 (string :tag "Description ")
2327 (repeat 2579 (repeat :tag "Component"
2328 (choice 2580 (choice
2329 (const :tag "Agenda" (agenda)) 2581 (list :tag "Agenda"
2330 (const :tag "TODO list" (alltodo)) 2582 (const :format "" agenda)
2331 (const :tag "Stuck projects" (stuck)) 2583 (const :tag "" :format "" "")
2584 ,org-agenda-custom-commands-local-options)
2585 (list :tag "TODO list (all keywords)"
2586 (const :format "" alltodo)
2587 (const :tag "" :format "" "")
2588 ,org-agenda-custom-commands-local-options)
2589 (list :tag "Search words"
2590 (const :format "" search)
2591 (string :tag "Match")
2592 ,org-agenda-custom-commands-local-options)
2593 (list :tag "Stuck projects"
2594 (const :format "" stuck)
2595 (const :tag "" :format "" "")
2596 ,org-agenda-custom-commands-local-options)
2332 (list :tag "Tags search" 2597 (list :tag "Tags search"
2333 (const :format "" tags) 2598 (const :format "" tags)
2334 (string :tag "Match") 2599 (string :tag "Match")
2335 (repeat :tag "Local options" 2600 ,org-agenda-custom-commands-local-options)
2336 (list (variable :tag "Option")
2337 (sexp :tag "Value"))))
2338
2339 (list :tag "Tags search, TODO entries only" 2601 (list :tag "Tags search, TODO entries only"
2340 (const :format "" tags-todo) 2602 (const :format "" tags-todo)
2341 (string :tag "Match") 2603 (string :tag "Match")
2342 (repeat :tag "Local options" 2604 ,org-agenda-custom-commands-local-options)
2343 (list (variable :tag "Option")
2344 (sexp :tag "Value"))))
2345
2346 (list :tag "TODO keyword search" 2605 (list :tag "TODO keyword search"
2347 (const :format "" todo) 2606 (const :format "" todo)
2348 (string :tag "Match") 2607 (string :tag "Match")
2349 (repeat :tag "Local options" 2608 ,org-agenda-custom-commands-local-options)
2350 (list (variable :tag "Option")
2351 (sexp :tag "Value"))))
2352
2353 (list :tag "Other, user-defined function" 2609 (list :tag "Other, user-defined function"
2354 (symbol :tag "function") 2610 (symbol :tag "function")
2355 (string :tag "Match") 2611 (string :tag "Match")
2356 (repeat :tag "Local options" 2612 ,org-agenda-custom-commands-local-options)))
2357 (list (variable :tag "Option")
2358 (sexp :tag "Value"))))))
2359 2613
2360 (repeat :tag "General options" 2614 (repeat :tag "Settings for entire command set"
2361 (list (variable :tag "Option") 2615 (list (variable :tag "Any variable")
2362 (sexp :tag "Value"))) 2616 (sexp :tag "Value")))
2363 (option (repeat :tag "Export" (file :tag "Export to")))) 2617 (option (repeat :tag "Export" (file :tag "Export to"))))
2364 (cons :tag "Prefix key documentation" 2618 (cons :tag "Prefix key documentation"
2365 (string :tag "Access Key(s)") 2619 (string :tag "Access Key(s)")
2366 (string :tag "Description "))))) 2620 (string :tag "Description ")))))
2367 2621
2622(defcustom org-agenda-query-register ?o
2623 "The register holding the current query string.
2624The prupose of this is that if you construct a query string interactively,
2625you can then use it to define a custom command."
2626 :group 'org-agenda-custom-commands
2627 :type 'character)
2628
2368(defcustom org-stuck-projects 2629(defcustom org-stuck-projects
2369 '("+LEVEL=2/-DONE" ("TODO" "NEXT" "NEXTACTION") nil "") 2630 '("+LEVEL=2/-DONE" ("TODO" "NEXT" "NEXTACTION") nil "")
2370 "How to identify stuck projects. 2631 "How to identify stuck projects.
@@ -2481,7 +2742,7 @@ N days, just insert a special line indicating the size of the gap."
2481 2742
2482(defcustom org-agenda-mouse-1-follows-link nil 2743(defcustom org-agenda-mouse-1-follows-link nil
2483 "Non-nil means, mouse-1 on a link will follow the link in the agenda. 2744 "Non-nil means, mouse-1 on a link will follow the link in the agenda.
2484A longer mouse click will still set point. Does not wortk on XEmacs. 2745A longer mouse click will still set point. Does not work on XEmacs.
2485Needs to be set before org.el is loaded." 2746Needs to be set before org.el is loaded."
2486 :group 'org-agenda-startup 2747 :group 'org-agenda-startup
2487 :type 'boolean) 2748 :type 'boolean)
@@ -2616,7 +2877,7 @@ nearest into the future."
2616(defcustom org-deadline-warning-days 14 2877(defcustom org-deadline-warning-days 14
2617 "No. of days before expiration during which a deadline becomes active. 2878 "No. of days before expiration during which a deadline becomes active.
2618This variable governs the display in sparse trees and in the agenda. 2879This variable governs the display in sparse trees and in the agenda.
2619When negative, it means use this number (the absolute value of it) 2880When 0 or negative, it means use this number (the absolute value of it)
2620even if a deadline has a different individual lead time specified." 2881even if a deadline has a different individual lead time specified."
2621 :group 'org-time 2882 :group 'org-time
2622 :group 'org-agenda-daily/weekly 2883 :group 'org-agenda-daily/weekly
@@ -2682,18 +2943,11 @@ a grid line."
2682 :tag "Org Agenda Sorting" 2943 :tag "Org Agenda Sorting"
2683 :group 'org-agenda) 2944 :group 'org-agenda)
2684 2945
2685(defconst org-sorting-choice
2686 '(choice
2687 (const time-up) (const time-down)
2688 (const category-keep) (const category-up) (const category-down)
2689 (const tag-down) (const tag-up)
2690 (const priority-up) (const priority-down))
2691 "Sorting choices.")
2692
2693(defcustom org-agenda-sorting-strategy 2946(defcustom org-agenda-sorting-strategy
2694 '((agenda time-up category-keep priority-down) 2947 '((agenda time-up category-keep priority-down)
2695 (todo category-keep priority-down) 2948 (todo category-keep priority-down)
2696 (tags category-keep priority-down)) 2949 (tags category-keep priority-down)
2950 (search category-keep))
2697 "Sorting structure for the agenda items of a single day. 2951 "Sorting structure for the agenda items of a single day.
2698This is a list of symbols which will be used in sequence to determine 2952This is a list of symbols which will be used in sequence to determine
2699if an entry should be listed before another entry. The following 2953if an entry should be listed before another entry. The following
@@ -2756,7 +3010,8 @@ agenda entries."
2756 '((agenda . " %-12:c%?-12t% s") 3010 '((agenda . " %-12:c%?-12t% s")
2757 (timeline . " % s") 3011 (timeline . " % s")
2758 (todo . " %-12:c") 3012 (todo . " %-12:c")
2759 (tags . " %-12:c")) 3013 (tags . " %-12:c")
3014 (search . " %-12:c"))
2760 "Format specifications for the prefix of items in the agenda views. 3015 "Format specifications for the prefix of items in the agenda views.
2761An alist with four entries, for the different agenda types. The keys to the 3016An alist with four entries, for the different agenda types. The keys to the
2762sublists are `agenda', `timeline', `todo', and `tags'. The values 3017sublists are `agenda', `timeline', `todo', and `tags'. The values
@@ -2811,7 +3066,8 @@ See also the variables `org-agenda-remove-times-when-in-prefix' and
2811 (cons (const agenda) (string :tag "Format")) 3066 (cons (const agenda) (string :tag "Format"))
2812 (cons (const timeline) (string :tag "Format")) 3067 (cons (const timeline) (string :tag "Format"))
2813 (cons (const todo) (string :tag "Format")) 3068 (cons (const todo) (string :tag "Format"))
2814 (cons (const tags) (string :tag "Format")))) 3069 (cons (const tags) (string :tag "Format"))
3070 (cons (const search) (string :tag "Format"))))
2815 :group 'org-agenda-line-format) 3071 :group 'org-agenda-line-format)
2816 3072
2817(defvar org-prefix-format-compiled nil 3073(defvar org-prefix-format-compiled nil
@@ -4077,7 +4333,7 @@ month and 365.24 days for a year)."
4077 )) 4333 ))
4078 4334
4079(defcustom org-n-level-faces (length org-level-faces) 4335(defcustom org-n-level-faces (length org-level-faces)
4080 "The number different faces to be used for headlines. 4336 "The number of different faces to be used for headlines.
4081Org-mode defines 8 different headline faces, so this can be at most 8. 4337Org-mode defines 8 different headline faces, so this can be at most 8.
4082If it is less than 8, the level-1 face gets re-used for level N+1 etc." 4338If it is less than 8, the level-1 face gets re-used for level N+1 etc."
4083 :type 'number 4339 :type 'number
@@ -4140,7 +4396,6 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc."
4140(declare-function elmo-folder-exists-p "ext:elmo" (folder) t) 4396(declare-function elmo-folder-exists-p "ext:elmo" (folder) t)
4141(declare-function elmo-message-entity-field "ext:elmo-msgdb" (entity field &optional type)) 4397(declare-function elmo-message-entity-field "ext:elmo-msgdb" (entity field &optional type))
4142(declare-function elmo-message-field "ext:elmo" (folder number field &optional type) t) 4398(declare-function elmo-message-field "ext:elmo" (folder number field &optional type) t)
4143;; backward compatibility to old version of elmo
4144(declare-function elmo-msgdb-overview-get-entity "ext:elmo" (&rest unknown) t) 4399(declare-function elmo-msgdb-overview-get-entity "ext:elmo" (&rest unknown) t)
4145(defvar font-lock-unfontify-region-function) 4400(defvar font-lock-unfontify-region-function)
4146(declare-function gnus-article-show-summary "gnus-art" ()) 4401(declare-function gnus-article-show-summary "gnus-art" ())
@@ -4174,6 +4429,7 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc."
4174(declare-function parse-time-string "parse-time" (string)) 4429(declare-function parse-time-string "parse-time" (string))
4175(declare-function remember "remember" (&optional initial)) 4430(declare-function remember "remember" (&optional initial))
4176(declare-function remember-buffer-desc "remember" ()) 4431(declare-function remember-buffer-desc "remember" ())
4432(declare-function remember-finalize "remember" ())
4177(defvar remember-save-after-remembering) 4433(defvar remember-save-after-remembering)
4178(defvar remember-data-file) 4434(defvar remember-data-file)
4179(defvar remember-register) 4435(defvar remember-register)
@@ -4183,6 +4439,7 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc."
4183(declare-function rmail-narrow-to-non-pruned-header "rmail" ()) 4439(declare-function rmail-narrow-to-non-pruned-header "rmail" ())
4184(declare-function rmail-show-message "rmail" (&optional n no-summary)) 4440(declare-function rmail-show-message "rmail" (&optional n no-summary))
4185(declare-function rmail-what-message "rmail" ()) 4441(declare-function rmail-what-message "rmail" ())
4442(defvar rmail-current-message)
4186(defvar texmathp-why) 4443(defvar texmathp-why)
4187(declare-function vm-beginning-of-message "ext:vm-page" ()) 4444(declare-function vm-beginning-of-message "ext:vm-page" ())
4188(declare-function vm-follow-summary-cursor "ext:vm-motion" ()) 4445(declare-function vm-follow-summary-cursor "ext:vm-motion" ())
@@ -4341,13 +4598,13 @@ we turn off invisibility temporarily. Use this in a `let' form."
4341 ("align" org-startup-align-all-tables t) 4598 ("align" org-startup-align-all-tables t)
4342 ("noalign" org-startup-align-all-tables nil) 4599 ("noalign" org-startup-align-all-tables nil)
4343 ("customtime" org-display-custom-times t) 4600 ("customtime" org-display-custom-times t)
4344 ("logging" org-log-done t) 4601 ("logdone" org-log-done time)
4345 ("logdone" org-log-done t) 4602 ("lognotedone" org-log-done note)
4346 ("nologging" org-log-done nil) 4603 ("nologdone" org-log-done nil)
4347 ("lognotedone" org-log-done done push) 4604 ("lognoteclock-out" org-log-note-clock-out t)
4348 ("lognotestate" org-log-done state push) 4605 ("nolognoteclock-out" org-log-note-clock-out nil)
4349 ("lognoteclock-out" org-log-done clock-out push) 4606 ("logrepeat" org-log-repeat state)
4350 ("logrepeat" org-log-repeat t) 4607 ("lognoterepeat" org-log-repeat note)
4351 ("nologrepeat" org-log-repeat nil) 4608 ("nologrepeat" org-log-repeat nil)
4352 ("constcgs" constants-unit-system cgs) 4609 ("constcgs" constants-unit-system cgs)
4353 ("constSI" constants-unit-system SI)) 4610 ("constSI" constants-unit-system SI))
@@ -4373,9 +4630,8 @@ means to push this value onto the list in the variable.")
4373 "STARTUP" "ARCHIVE" "TAGS" "LINK" "PRIORITIES" 4630 "STARTUP" "ARCHIVE" "TAGS" "LINK" "PRIORITIES"
4374 "CONSTANTS" "PROPERTY" "DRAWERS"))) 4631 "CONSTANTS" "PROPERTY" "DRAWERS")))
4375 (splitre "[ \t]+") 4632 (splitre "[ \t]+")
4376 kwds kws0 kwsa key value cat arch tags const links hw dws 4633 kwds kws0 kwsa key log value cat arch tags const links hw dws
4377 tail sep kws1 prio props drawers 4634 tail sep kws1 prio props drawers)
4378 ex log)
4379 (save-excursion 4635 (save-excursion
4380 (save-restriction 4636 (save-restriction
4381 (widen) 4637 (widen)
@@ -4457,15 +4713,14 @@ means to push this value onto the list in the variable.")
4457 kwsa nil 4713 kwsa nil
4458 kws1 (mapcar 4714 kws1 (mapcar
4459 (lambda (x) 4715 (lambda (x)
4460 (if (string-match "^\\(.*?\\)\\(?:(\\(..?\\))\\)?$" x) 4716 ;; 1 2
4717 (if (string-match "^\\(.*?\\)\\(?:(\\([^!@/]\\)?.*?)\\)?$" x)
4461 (progn 4718 (progn
4462 (setq kw (match-string 1 x) 4719 (setq kw (match-string 1 x)
4463 ex (and (match-end 2) (match-string 2 x)) 4720 key (and (match-end 2) (match-string 2 x))
4464 log (and ex (string-match "@" ex)) 4721 log (org-extract-log-state-settings x))
4465 key (and ex (substring ex 0 1)))
4466 (if (equal key "@") (setq key nil))
4467 (push (cons kw (and key (string-to-char key))) kwsa) 4722 (push (cons kw (and key (string-to-char key))) kwsa)
4468 (and log (push kw org-todo-log-states)) 4723 (and log (push log org-todo-log-states))
4469 kw) 4724 kw)
4470 (error "Invalid TODO keyword %s" x))) 4725 (error "Invalid TODO keyword %s" x)))
4471 kws0) 4726 kws0)
@@ -4589,9 +4844,24 @@ means to push this value onto the list in the variable.")
4589 (org-compute-latex-and-specials-regexp) 4844 (org-compute-latex-and-specials-regexp)
4590 (org-set-font-lock-defaults))) 4845 (org-set-font-lock-defaults)))
4591 4846
4847(defun org-extract-log-state-settings (x)
4848 "Extract the log state setting from a TODO keyword string.
4849This will extract info from a string like \"WAIT(w@/!)\"."
4850 (let (kw key log1 log2)
4851 (when (string-match "^\\(.*?\\)\\(?:(\\([^!@/]\\)?\\([!@]\\)?\\(?:/\\([!@]\\)\\)?)\\)?$" x)
4852 (setq kw (match-string 1 x)
4853 key (and (match-end 2) (match-string 2 x))
4854 log1 (and (match-end 3) (match-string 3 x))
4855 log2 (and (match-end 4) (match-string 4 x)))
4856 (and (or log1 log2)
4857 (list kw
4858 (and log1 (if (equal log1 "!") 'time 'note))
4859 (and log2 (if (equal log2 "!") 'time 'note)))))))
4860
4592(defun org-remove-keyword-keys (list) 4861(defun org-remove-keyword-keys (list)
4862 "Remove a pair of parenthesis at the end of each string in LIST."
4593 (mapcar (lambda (x) 4863 (mapcar (lambda (x)
4594 (if (string-match "(..?)$" x) 4864 (if (string-match "(.*)$" x)
4595 (substring x 0 (match-beginning 0)) 4865 (substring x 0 (match-beginning 0))
4596 x)) 4866 x))
4597 list)) 4867 list))
@@ -4861,6 +5131,13 @@ The following commands are available:
4861; (org-set-local 'comment-start "#") ;; FIXME: this breaks wrapping 5131; (org-set-local 'comment-start "#") ;; FIXME: this breaks wrapping
4862 (org-set-local 'comment-padding " ") 5132 (org-set-local 'comment-padding " ")
4863 5133
5134 ;; Align options lines
5135 (org-set-local
5136 'align-mode-rules-list
5137 '((org-in-buffer-settings
5138 (regexp . "^#\\+[A-Z_]+:\\(\\s-*\\)\\S-+")
5139 (modes . '(org-mode)))))
5140
4864 ;; Imenu 5141 ;; Imenu
4865 (org-set-local 'imenu-create-index-function 5142 (org-set-local 'imenu-create-index-function
4866 'org-imenu-get-tree) 5143 'org-imenu-get-tree)
@@ -4907,8 +5184,8 @@ The following commands are available:
4907 5184
4908(defun org-current-time () 5185(defun org-current-time ()
4909 "Current time, possibly rounded to `org-time-stamp-rounding-minutes'." 5186 "Current time, possibly rounded to `org-time-stamp-rounding-minutes'."
4910 (if (> org-time-stamp-rounding-minutes 0) 5187 (if (> (car org-time-stamp-rounding-minutes) 1)
4911 (let ((r org-time-stamp-rounding-minutes) 5188 (let ((r (car org-time-stamp-rounding-minutes))
4912 (time (decode-time))) 5189 (time (decode-time)))
4913 (apply 'encode-time 5190 (apply 'encode-time
4914 (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r))))) 5191 (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r)))))
@@ -4991,7 +5268,7 @@ This should be called after the variable `org-link-types' has changed."
4991 org-plain-link-re 5268 org-plain-link-re
4992 (concat 5269 (concat
4993 "\\<\\(" (mapconcat 'identity org-link-types "\\|") "\\):" 5270 "\\<\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
4994 "\\([^]\t\n\r<>,;() ]+\\)") 5271 "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)")
4995 org-bracket-link-regexp 5272 org-bracket-link-regexp
4996 "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]" 5273 "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]"
4997 org-bracket-link-analytic-regexp 5274 org-bracket-link-analytic-regexp
@@ -5013,10 +5290,11 @@ This should be called after the variable `org-link-types' has changed."
5013 "Regular expression for fast time stamp matching.") 5290 "Regular expression for fast time stamp matching.")
5014(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^\r\n>]*?\\)[]>]" 5291(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^\r\n>]*?\\)[]>]"
5015 "Regular expression for fast time stamp matching.") 5292 "Regular expression for fast time stamp matching.")
5016(defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)\\([^]0-9>\r\n]*\\)\\(\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)" 5293(defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]-+0-9>\r\n ]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
5017 "Regular expression matching time strings for analysis. 5294 "Regular expression matching time strings for analysis.
5018This one does not require the space after the date.") 5295This one does not require the space after the date, so it can be used
5019(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) \\([^]0-9>\r\n]*\\)\\(\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)" 5296on a string that terminates immediately after the date.")
5297(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) +\\([^]-+0-9>\r\n ]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
5020 "Regular expression matching time strings for analysis.") 5298 "Regular expression matching time strings for analysis.")
5021(defconst org-ts-regexp2 (concat "<" org-ts-regexp1 "[^>\n]\\{0,16\\}>") 5299(defconst org-ts-regexp2 (concat "<" org-ts-regexp1 "[^>\n]\\{0,16\\}>")
5022 "Regular expression matching time stamps, with groups.") 5300 "Regular expression matching time stamps, with groups.")
@@ -5832,19 +6110,24 @@ Optional argument N means, put the headline into the Nth line of the window."
5832 (substitute-key-definition cmd cmd map global-map))) 6110 (substitute-key-definition cmd cmd map global-map)))
5833 (suppress-keymap map) 6111 (suppress-keymap map)
5834 (org-defkey map "\C-m" 'org-goto-ret) 6112 (org-defkey map "\C-m" 'org-goto-ret)
6113 (org-defkey map [(return)] 'org-goto-ret)
5835 (org-defkey map [(left)] 'org-goto-left) 6114 (org-defkey map [(left)] 'org-goto-left)
5836 (org-defkey map [(right)] 'org-goto-right) 6115 (org-defkey map [(right)] 'org-goto-right)
5837 (org-defkey map [(?q)] 'org-goto-quit)
5838 (org-defkey map [(control ?g)] 'org-goto-quit) 6116 (org-defkey map [(control ?g)] 'org-goto-quit)
5839 (org-defkey map "\C-i" 'org-cycle) 6117 (org-defkey map "\C-i" 'org-cycle)
5840 (org-defkey map [(tab)] 'org-cycle) 6118 (org-defkey map [(tab)] 'org-cycle)
5841 (org-defkey map [(down)] 'outline-next-visible-heading) 6119 (org-defkey map [(down)] 'outline-next-visible-heading)
5842 (org-defkey map [(up)] 'outline-previous-visible-heading) 6120 (org-defkey map [(up)] 'outline-previous-visible-heading)
5843 (org-defkey map "n" 'outline-next-visible-heading) 6121 (if org-goto-auto-isearch
5844 (org-defkey map "p" 'outline-previous-visible-heading) 6122 (if (fboundp 'define-key-after)
5845 (org-defkey map "f" 'outline-forward-same-level) 6123 (define-key-after map [t] 'org-goto-local-auto-isearch)
5846 (org-defkey map "b" 'outline-backward-same-level) 6124 nil)
5847 (org-defkey map "u" 'outline-up-heading) 6125 (org-defkey map "q" 'org-goto-quit)
6126 (org-defkey map "n" 'outline-next-visible-heading)
6127 (org-defkey map "p" 'outline-previous-visible-heading)
6128 (org-defkey map "f" 'outline-forward-same-level)
6129 (org-defkey map "b" 'outline-backward-same-level)
6130 (org-defkey map "u" 'outline-up-heading))
5848 (org-defkey map "/" 'org-occur) 6131 (org-defkey map "/" 'org-occur)
5849 (org-defkey map "\C-c\C-n" 'outline-next-visible-heading) 6132 (org-defkey map "\C-c\C-n" 'outline-next-visible-heading)
5850 (org-defkey map "\C-c\C-p" 'outline-previous-visible-heading) 6133 (org-defkey map "\C-c\C-p" 'outline-previous-visible-heading)
@@ -5854,14 +6137,13 @@ Optional argument N means, put the headline into the Nth line of the window."
5854 map)) 6137 map))
5855 6138
5856(defconst org-goto-help 6139(defconst org-goto-help
5857"Browse copy of buffer to find location or copy text. 6140"Browse buffer copy, to find location or copy text. Just type for auto-isearch.
5858RET=jump to location [Q]uit and return to previous location 6141RET=jump to location [Q]uit and return to previous location
5859\[Up]/[Down]=next/prev headline TAB=cycle visibility [/] org-occur" 6142\[Up]/[Down]=next/prev headline TAB=cycle visibility [/] org-occur")
5860)
5861 6143
5862(defvar org-goto-start-pos) ; dynamically scoped parameter 6144(defvar org-goto-start-pos) ; dynamically scoped parameter
5863 6145
5864(defun org-goto () 6146(defun org-goto (&optional alternative-interface)
5865 "Look up a different location in the current file, keeping current visibility. 6147 "Look up a different location in the current file, keeping current visibility.
5866 6148
5867When you want look-up or go to a different location in a document, the 6149When you want look-up or go to a different location in a document, the
@@ -5876,10 +6158,20 @@ When pressing RET or `Q', the command returns to the original buffer in
5876which the visibility is still unchanged. After RET is will also jump to 6158which the visibility is still unchanged. After RET is will also jump to
5877the location selected in the indirect buffer and expose the 6159the location selected in the indirect buffer and expose the
5878the headline hierarchy above." 6160the headline hierarchy above."
5879 (interactive) 6161 (interactive "P")
5880 (let* ((org-goto-start-pos (point)) 6162 (let* ((org-refile-targets '((nil . (:maxlevel . 10))))
6163 (org-refile-use-outline-path t)
6164 (interface
6165 (if (not alternative-interface)
6166 org-goto-interface
6167 (if (eq org-goto-interface 'outline)
6168 'outline-path-completion
6169 'outline)))
6170 (org-goto-start-pos (point))
5881 (selected-point 6171 (selected-point
5882 (car (org-get-location (current-buffer) org-goto-help)))) 6172 (if (eq interface 'outline)
6173 (car (org-get-location (current-buffer) org-goto-help))
6174 (nth 3 (org-refile-get-location "Goto: ")))))
5883 (if selected-point 6175 (if selected-point
5884 (progn 6176 (progn
5885 (org-mark-ring-push org-goto-start-pos) 6177 (org-mark-ring-push org-goto-start-pos)
@@ -5890,12 +6182,17 @@ the headline hierarchy above."
5890 6182
5891(defvar org-goto-selected-point nil) ; dynamically scoped parameter 6183(defvar org-goto-selected-point nil) ; dynamically scoped parameter
5892(defvar org-goto-exit-command nil) ; dynamically scoped parameter 6184(defvar org-goto-exit-command nil) ; dynamically scoped parameter
6185(defvar org-goto-local-auto-isearch-map) ; defined below
5893 6186
5894(defun org-get-location (buf help) 6187(defun org-get-location (buf help)
5895 "Let the user select a location in the Org-mode buffer BUF. 6188 "Let the user select a location in the Org-mode buffer BUF.
5896This function uses a recursive edit. It returns the selected position 6189This function uses a recursive edit. It returns the selected position
5897or nil." 6190or nil."
5898 (let (org-goto-selected-point org-goto-exit-command) 6191 (let ((isearch-mode-map org-goto-local-auto-isearch-map)
6192 (isearch-hide-immediately nil)
6193 (isearch-search-fun-function
6194 (lambda () 'org-goto-local-search-forward-headings))
6195 (org-goto-selected-point org-goto-exit-command))
5899 (save-excursion 6196 (save-excursion
5900 (save-window-excursion 6197 (save-window-excursion
5901 (delete-other-windows) 6198 (delete-other-windows)
@@ -5924,21 +6221,35 @@ or nil."
5924 (goto-char (point-min))) 6221 (goto-char (point-min)))
5925 (org-beginning-of-line) 6222 (org-beginning-of-line)
5926 (message "Select location and press RET") 6223 (message "Select location and press RET")
5927 ;; now we make sure that during selection, ony very few keys work
5928 ;; and that it is impossible to switch to another window.
5929; (let ((gm (current-global-map))
5930; (overriding-local-map org-goto-map))
5931; (unwind-protect
5932; (progn
5933; (use-global-map org-goto-map)
5934; (recursive-edit))
5935; (use-global-map gm)))
5936 (use-local-map org-goto-map) 6224 (use-local-map org-goto-map)
5937 (recursive-edit) 6225 (recursive-edit)
5938 )) 6226 ))
5939 (kill-buffer "*org-goto*") 6227 (kill-buffer "*org-goto*")
5940 (cons org-goto-selected-point org-goto-exit-command))) 6228 (cons org-goto-selected-point org-goto-exit-command)))
5941 6229
6230(defvar org-goto-local-auto-isearch-map (make-sparse-keymap))
6231(set-keymap-parent org-goto-local-auto-isearch-map isearch-mode-map)
6232(define-key org-goto-local-auto-isearch-map "\C-i" 'isearch-other-control-char)
6233(define-key org-goto-local-auto-isearch-map "\C-m" 'isearch-other-control-char)
6234
6235(defun org-goto-local-search-forward-headings (string bound noerror)
6236 "Search and make sure that anu matches are in headlines."
6237 (catch 'return
6238 (while (search-forward string bound noerror)
6239 (when (let ((context (mapcar 'car (save-match-data (org-context)))))
6240 (and (member :headline context)
6241 (not (member :tags context))))
6242 (throw 'return (point))))))
6243
6244(defun org-goto-local-auto-isearch ()
6245 "Start isearch."
6246 (interactive)
6247 (goto-char (point-min))
6248 (let ((keys (this-command-keys)))
6249 (when (eq (lookup-key isearch-mode-map keys) 'isearch-printing-char)
6250 (isearch-mode t)
6251 (isearch-process-search-char (string-to-char keys)))))
6252
5942(defun org-goto-ret (&optional arg) 6253(defun org-goto-ret (&optional arg)
5943 "Finish `org-goto' by going to the new location." 6254 "Finish `org-goto' by going to the new location."
5944 (interactive "P") 6255 (interactive "P")
@@ -6065,9 +6376,8 @@ frame is not changed."
6065 "Insert a new heading or item with same depth at point. 6376 "Insert a new heading or item with same depth at point.
6066If point is in a plain list and FORCE-HEADING is nil, create a new list item. 6377If point is in a plain list and FORCE-HEADING is nil, create a new list item.
6067If point is at the beginning of a headline, insert a sibling before the 6378If point is at the beginning of a headline, insert a sibling before the
6068current headline. If point is in the middle of a headline, split the headline 6379current headline. If point is not at the beginning, do not split the line,
6069at that position and make the rest of the headline part of the sibling below 6380but create the new hedline after the current line."
6070the current headline."
6071 (interactive "P") 6381 (interactive "P")
6072 (if (= (buffer-size) 0) 6382 (if (= (buffer-size) 0)
6073 (insert "\n* ") 6383 (insert "\n* ")
@@ -6084,13 +6394,58 @@ the current headline."
6084 ((and (org-on-heading-p) (bolp) 6394 ((and (org-on-heading-p) (bolp)
6085 (or (bobp) 6395 (or (bobp)
6086 (save-excursion (backward-char 1) (not (org-invisible-p))))) 6396 (save-excursion (backward-char 1) (not (org-invisible-p)))))
6397 ;; insert before the current line
6087 (open-line (if blank 2 1))) 6398 (open-line (if blank 2 1)))
6088 ((and (bolp) 6399 ((and (bolp)
6089 (or (bobp) 6400 (or (bobp)
6090 (save-excursion 6401 (save-excursion
6091 (backward-char 1) (not (org-invisible-p))))) 6402 (backward-char 1) (not (org-invisible-p)))))
6403 ;; insert right here
6092 nil) 6404 nil)
6093 (t (newline (if blank 2 1)))) 6405 (t
6406; ;; in the middle of the line
6407; (org-show-entry)
6408; (if (org-get-alist-option org-M-RET-may-split-line 'headline)
6409; (if (and
6410; (org-on-heading-p)
6411; (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \r\n]"))
6412; ;; protect the tags
6413;; (let ((tags (match-string 2)) pos)
6414; (delete-region (match-beginning 1) (match-end 1))
6415; (setq pos (point-at-bol))
6416; (newline (if blank 2 1))
6417; (save-excursion
6418; (goto-char pos)
6419; (end-of-line 1)
6420; (insert " " tags)
6421; (org-set-tags nil 'align)))
6422; (newline (if blank 2 1)))
6423; (newline (if blank 2 1))))
6424
6425
6426 ;; in the middle of the line
6427 (org-show-entry)
6428 (let ((split
6429 (org-get-alist-option org-M-RET-may-split-line 'headline))
6430 tags pos)
6431 (if (org-on-heading-p)
6432 (progn
6433 (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
6434 (setq tags (and (match-end 2) (match-string 2)))
6435 (and (match-end 1)
6436 (delete-region (match-beginning 1) (match-end 1)))
6437 (setq pos (point-at-bol))
6438 (or split (end-of-line 1))
6439 (delete-horizontal-space)
6440 (newline (if blank 2 1))
6441 (when tags
6442 (save-excursion
6443 (goto-char pos)
6444 (end-of-line 1)
6445 (insert " " tags)
6446 (org-set-tags nil 'align))))
6447 (or split (end-of-line 1))
6448 (newline (if blank 2 1))))))
6094 (insert head) (just-one-space) 6449 (insert head) (just-one-space)
6095 (setq pos (point)) 6450 (setq pos (point))
6096 (end-of-line 1) 6451 (end-of-line 1)
@@ -6566,9 +6921,10 @@ If optional TXT is given, check this string instead of the current kill."
6566 "Narrow buffer to the current subtree." 6921 "Narrow buffer to the current subtree."
6567 (interactive) 6922 (interactive)
6568 (save-excursion 6923 (save-excursion
6569 (narrow-to-region 6924 (save-match-data
6570 (progn (org-back-to-heading) (point)) 6925 (narrow-to-region
6571 (progn (org-end-of-subtree t t) (point))))) 6926 (progn (org-back-to-heading) (point))
6927 (progn (org-end-of-subtree t t) (point))))))
6572 6928
6573 6929
6574;;; Outline Sorting 6930;;; Outline Sorting
@@ -6815,7 +7171,7 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
6815 (cond 7171 (cond
6816 ((eq llt t) "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") 7172 ((eq llt t) "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
6817 ((= llt ?.) "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") 7173 ((= llt ?.) "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
6818 ((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+)\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") 7174 ((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+))\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
6819 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'"))))))) 7175 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))))))
6820 7176
6821(defun org-in-item-p () 7177(defun org-in-item-p ()
@@ -6852,7 +7208,11 @@ Return t when things worked, nil when we are not in an item."
6852 (open-line (if blank 2 1))) 7208 (open-line (if blank 2 1)))
6853 ((<= (point) eow) 7209 ((<= (point) eow)
6854 (beginning-of-line 1)) 7210 (beginning-of-line 1))
6855 (t (newline (if blank 2 1)))) 7211 (t
7212 (unless (org-get-alist-option org-M-RET-may-split-line 'item)
7213 (end-of-line 1)
7214 (delete-horizontal-space))
7215 (newline (if blank 2 1))))
6856 (insert bul (if checkbox "[ ]" "")) 7216 (insert bul (if checkbox "[ ]" ""))
6857 (just-one-space) 7217 (just-one-space)
6858 (setq pos (point)) 7218 (setq pos (point))
@@ -6910,52 +7270,90 @@ Return t when things worked, nil when we are not in an item."
6910 (org-update-checkbox-count))) 7270 (org-update-checkbox-count)))
6911 7271
6912(defun org-update-checkbox-count (&optional all) 7272(defun org-update-checkbox-count (&optional all)
6913 "Update the checkbox statistics in the current section. 7273 "Update the checkbox statistics in the current section.
6914This will find all statistic cookies like [57%] and [6/12] and update them 7274This will find all statistic cookies like [57%] and [6/12] and update them
6915with the current numbers. With optional prefix argument ALL, do this for 7275with the current numbers. With optional prefix argument ALL, do this for
6916the whole buffer." 7276the whole buffer."
6917 (interactive "P") 7277 (interactive "P")
6918 (save-excursion 7278 (save-excursion
6919 (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21 7279 (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
6920 (beg (condition-case nil 7280 (beg (condition-case nil
6921 (progn (outline-back-to-heading) (point)) 7281 (progn (outline-back-to-heading) (point))
6922 (error (point-min)))) 7282 (error (point-min))))
6923 (end (move-marker (make-marker) 7283 (end (move-marker (make-marker)
6924 (progn (outline-next-heading) (point)))) 7284 (progn (outline-next-heading) (point))))
6925 (re "\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)") 7285 (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
6926 (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)") 7286 (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
6927 b1 e1 f1 c-on c-off lim (cstat 0)) 7287 (re-find (concat re "\\|" re-box))
6928 (when all 7288 beg-cookie end-cookie is-percent c-on c-off lim
6929 (goto-char (point-min)) 7289 eline curr-ind next-ind continue-from startsearch
6930 (outline-next-heading) 7290 (cstat 0)
6931 (setq beg (point) end (point-max))) 7291 )
6932 (goto-char beg) 7292 (when all
6933 (while (re-search-forward re end t) 7293 (goto-char (point-min))
6934 (setq cstat (1+ cstat) 7294 (outline-next-heading)
6935 b1 (match-beginning 0) 7295 (setq beg (point) end (point-max)))
6936 e1 (match-end 0) 7296 (goto-char end)
6937 f1 (match-beginning 1) 7297 ;; find each statistic cookie
6938 lim (cond 7298 (while (re-search-backward re-find beg t)
6939 ((org-on-heading-p) (outline-next-heading) (point)) 7299 (setq beg-cookie (match-beginning 1)
6940 ((org-at-item-p) (org-end-of-item) (point)) 7300 end-cookie (match-end 1)
6941 (t nil)) 7301 cstat (+ cstat (if end-cookie 1 0))
6942 c-on 0 c-off 0) 7302 startsearch (point-at-eol)
6943 (goto-char e1) 7303 continue-from (point-at-bol)
6944 (when lim 7304 is-percent (match-beginning 2)
6945 (while (re-search-forward re-box lim t) 7305 lim (cond
6946 (if (member (match-string 2) '("[ ]" "[-]")) 7306 ((org-on-heading-p) (outline-next-heading) (point))
6947 (setq c-off (1+ c-off)) 7307 ((org-at-item-p) (org-end-of-item) (point))
6948 (setq c-on (1+ c-on)))) 7308 (t nil))
6949; (delete-region b1 e1) 7309 c-on 0
6950 (goto-char b1) 7310 c-off 0)
6951 (insert (if f1 7311 (when lim
6952 (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off)))) 7312 ;; find first checkbox for this cookie and gather
6953 (format "[%d/%d]" c-on (+ c-on c-off)))) 7313 ;; statistics from all that are at this indentation level
6954 (and (looking-at "\\[.*?\\]") 7314 (goto-char startsearch)
6955 (replace-match "")))) 7315 (if (re-search-forward re-box lim t)
6956 (when (interactive-p) 7316 (progn
6957 (message "Checkbox satistics updated %s (%d places)" 7317 (org-beginning-of-item)
6958 (if all "in entire file" "in current outline entry") cstat))))) 7318 (setq curr-ind (org-get-indentation))
7319 (setq next-ind curr-ind)
7320 (while (= curr-ind next-ind)
7321 (save-excursion (end-of-line) (setq eline (point)))
7322 (if (re-search-forward re-box eline t)
7323 (if (member (match-string 2) '("[ ]" "[-]"))
7324 (setq c-off (1+ c-off))
7325 (setq c-on (1+ c-on))
7326 )
7327 )
7328 (org-end-of-item)
7329 (setq next-ind (org-get-indentation))
7330 )))
7331 (goto-char continue-from)
7332 ;; update cookie
7333 (when end-cookie
7334 (delete-region beg-cookie end-cookie)
7335 (goto-char beg-cookie)
7336 (insert
7337 (if is-percent
7338 (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
7339 (format "[%d/%d]" c-on (+ c-on c-off)))))
7340 ;; update items checkbox if it has one
7341 (when (org-at-item-p)
7342 (org-beginning-of-item)
7343 (when (and (> (+ c-on c-off) 0)
7344 (re-search-forward re-box (point-at-eol) t))
7345 (setq beg-cookie (match-beginning 2)
7346 end-cookie (match-end 2))
7347 (delete-region beg-cookie end-cookie)
7348 (goto-char beg-cookie)
7349 (cond ((= c-off 0) (insert "[X]"))
7350 ((= c-on 0) (insert "[ ]"))
7351 (t (insert "[-]")))
7352 )))
7353 (goto-char continue-from))
7354 (when (interactive-p)
7355 (message "Checkbox satistics updated %s (%d places)"
7356 (if all "in entire file" "in current outline entry") cstat)))))
6959 7357
6960(defun org-get-checkbox-statistics-face () 7358(defun org-get-checkbox-statistics-face ()
6961 "Select the face for checkbox statistics. 7359 "Select the face for checkbox statistics.
@@ -7160,8 +7558,8 @@ so this really moves item trees."
7160Subitems (items with larger indentation) are considered part of the item, 7558Subitems (items with larger indentation) are considered part of the item,
7161so this really moves item trees." 7559so this really moves item trees."
7162 (interactive "p") 7560 (interactive "p")
7163 (let (beg beg0 end end0 ind ind1 (pos (point)) txt 7561 (let (beg beg0 end ind ind1 (pos (point)) txt
7164 ne-beg ne-end ne-ins ins-end) 7562 ne-beg ne-ins ins-end)
7165 (org-beginning-of-item) 7563 (org-beginning-of-item)
7166 (setq beg0 (point)) 7564 (setq beg0 (point))
7167 (setq ind (org-get-indentation)) 7565 (setq ind (org-get-indentation))
@@ -7170,7 +7568,6 @@ so this really moves item trees."
7170 (setq beg (point))) 7568 (setq beg (point)))
7171 (goto-char beg0) 7569 (goto-char beg0)
7172 (org-end-of-item) 7570 (org-end-of-item)
7173 (setq ne-end (org-back-over-empty-lines))
7174 (setq end (point)) 7571 (setq end (point))
7175 (goto-char beg0) 7572 (goto-char beg0)
7176 (catch 'exit 7573 (catch 'exit
@@ -7695,6 +8092,7 @@ this heading."
7695 ;; start of variables that will be used for saving context 8092 ;; start of variables that will be used for saving context
7696 ;; The compiler complains about them - keep them anyway! 8093 ;; The compiler complains about them - keep them anyway!
7697 (file (abbreviate-file-name (buffer-file-name))) 8094 (file (abbreviate-file-name (buffer-file-name)))
8095 (olpath (mapconcat 'identity (org-get-outline-path) "/"))
7698 (time (format-time-string 8096 (time (format-time-string
7699 (substring (cdr org-time-stamp-formats) 1 -1) 8097 (substring (cdr org-time-stamp-formats) 1 -1)
7700 (current-time))) 8098 (current-time)))
@@ -7769,6 +8167,7 @@ this heading."
7769 org-odd-levels-only 8167 org-odd-levels-only
7770 tr-org-odd-levels-only))) 8168 tr-org-odd-levels-only)))
7771 (goto-char (point-min)) 8169 (goto-char (point-min))
8170 (show-all)
7772 (if heading 8171 (if heading
7773 (progn 8172 (progn
7774 (if (re-search-forward 8173 (if (re-search-forward
@@ -7797,7 +8196,7 @@ this heading."
7797 (looking-at org-todo-line-regexp) 8196 (looking-at org-todo-line-regexp)
7798 (or (not (match-end 2)) 8197 (or (not (match-end 2))
7799 (not (member (match-string 2) org-done-keywords)))) 8198 (not (member (match-string 2) org-done-keywords))))
7800 (let (org-log-done) 8199 (let (org-log-done org-todo-log-states)
7801 (org-todo 8200 (org-todo
7802 (car (or (member org-archive-mark-done org-done-keywords) 8201 (car (or (member org-archive-mark-done org-done-keywords)
7803 org-done-keywords))))) 8202 org-done-keywords)))))
@@ -7811,8 +8210,9 @@ this heading."
7811 (setq n (concat "ARCHIVE_" (upcase (symbol-name e)))) 8210 (setq n (concat "ARCHIVE_" (upcase (symbol-name e))))
7812 (org-entry-put (point) n v))))) 8211 (org-entry-put (point) n v)))))
7813 8212
7814 ;; Save the buffer, if it is not the same buffer. 8213 ;; Save and kill the buffer, if it is not the same buffer.
7815 (if (not (eq this-buffer buffer)) (save-buffer)))) 8214 (if (not (eq this-buffer buffer))
8215 (progn (save-buffer) (kill-buffer buffer)))))
7816 ;; Here we are back in the original buffer. Everything seems to have 8216 ;; Here we are back in the original buffer. Everything seems to have
7817 ;; worked. So now cut the tree and finish up. 8217 ;; worked. So now cut the tree and finish up.
7818 (let (this-command) (org-cut-subtree)) 8218 (let (this-command) (org-cut-subtree))
@@ -7867,7 +8267,7 @@ When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag."
7867 (progn 8267 (progn
7868 (setq re1 (concat "^" (regexp-quote 8268 (setq re1 (concat "^" (regexp-quote
7869 (make-string 8269 (make-string
7870 (1+ (- (match-end 0) (match-beginning 0))) 8270 (1+ (- (match-end 0) (match-beginning 0) 1))
7871 ?*)) 8271 ?*))
7872 " ")) 8272 " "))
7873 (move-marker begm (point)) 8273 (move-marker begm (point))
@@ -9283,6 +9683,8 @@ blank, and the content is appended to the field above."
9283 (org-table-goto-column ccol) 9683 (org-table-goto-column ccol)
9284 (org-table-paste-rectangle)) 9684 (org-table-paste-rectangle))
9285 ;; No region, split the current field at point 9685 ;; No region, split the current field at point
9686 (unless (org-get-alist-option org-M-RET-may-split-line 'table)
9687 (skip-chars-forward "^\r\n|"))
9286 (if arg 9688 (if arg
9287 ;; combine with field above 9689 ;; combine with field above
9288 (let ((s (org-table-blank-field)) 9690 (let ((s (org-table-blank-field))
@@ -9295,13 +9697,14 @@ blank, and the content is appended to the field above."
9295 (insert " " (org-trim s)) 9697 (insert " " (org-trim s))
9296 (org-table-align)) 9698 (org-table-align))
9297 ;; split field 9699 ;; split field
9298 (when (looking-at "\\([^|]+\\)+|") 9700 (if (looking-at "\\([^|]+\\)+|")
9299 (let ((s (match-string 1))) 9701 (let ((s (match-string 1)))
9300 (replace-match " |") 9702 (replace-match " |")
9301 (goto-char (match-beginning 0)) 9703 (goto-char (match-beginning 0))
9302 (org-table-next-row) 9704 (org-table-next-row)
9303 (insert (org-trim s) " ") 9705 (insert (org-trim s) " ")
9304 (org-table-align)))))) 9706 (org-table-align))
9707 (org-table-next-row)))))
9305 9708
9306(defvar org-field-marker nil) 9709(defvar org-field-marker nil)
9307 9710
@@ -11233,7 +11636,7 @@ to execute outside of tables."
11233 ["Move Row Down" org-metadown :active (org-at-table-p) :keys "M-<down>"] 11636 ["Move Row Down" org-metadown :active (org-at-table-p) :keys "M-<down>"]
11234 ["Delete Row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"] 11637 ["Delete Row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"]
11235 ["Insert Row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"] 11638 ["Insert Row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"]
11236 ["Sort lines in region" org-table-sort-lines (org-at-table-p) :keys "C-c ^"] 11639 ["Sort lines in region" org-table-sort-lines :active (org-at-table-p) :keys "C-c ^"]
11237 "--" 11640 "--"
11238 ["Insert Hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"]) 11641 ["Insert Hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"])
11239 ("Rectangle" 11642 ("Rectangle"
@@ -11522,7 +11925,7 @@ Valid parameters are
11522 %s for the original field value. For example, to wrap 11925 %s for the original field value. For example, to wrap
11523 everything in dollars, you could use :fmt \"$%s$\". 11926 everything in dollars, you could use :fmt \"$%s$\".
11524 This may also be a property list with column numbers and 11927 This may also be a property list with column numbers and
11525 formats. for example :fmt (2 \"$%s$\" 4 \"%s%%\") 11928 formats. For example :fmt (2 \"$%s$\" 4 \"%s%%\")
11526 11929
11527:hlstart :hlend :hlsep :hlfmt :hfmt 11930:hlstart :hlend :hlsep :hlfmt :hfmt
11528 Same as above, specific for the header lines in the table. 11931 Same as above, specific for the header lines in the table.
@@ -11598,7 +12001,7 @@ LaTeX are:
11598:fmt A format to be used to wrap the field, should contain %s for the 12001:fmt A format to be used to wrap the field, should contain %s for the
11599 original field value. For example, to wrap everything in dollars, 12002 original field value. For example, to wrap everything in dollars,
11600 use :fmt \"$%s$\". This may also be a property list with column 12003 use :fmt \"$%s$\". This may also be a property list with column
11601 numbers and formats. for example :fmt (2 \"$%s$\" 4 \"%s%%\") 12004 numbers and formats. For example :fmt (2 \"$%s$\" 4 \"%s%%\")
11602 12005
11603:efmt Format for transforming numbers with exponentials. The format 12006:efmt Format for transforming numbers with exponentials. The format
11604 should have %s twice for inserting mantissa and exponent, for 12007 should have %s twice for inserting mantissa and exponent, for
@@ -11661,7 +12064,7 @@ TeXInfo are:
11661 %s for the original field value. For example, to wrap 12064 %s for the original field value. For example, to wrap
11662 everything in @kbd{}, you could use :fmt \"@kbd{%s}\". 12065 everything in @kbd{}, you could use :fmt \"@kbd{%s}\".
11663 This may also be a property list with column numbers and 12066 This may also be a property list with column numbers and
11664 formats. For example :fmt (2 \"@kbd{%s}\" 4 \"@code{%s}\"). 12067 formats. For example :fmt (2 \"@kbd{%s}\" 4 \"@code{%s}\").
11665 12068
11666:cf \"f1 f2..\" The column fractions for the table. By default these 12069:cf \"f1 f2..\" The column fractions for the table. By default these
11667 are computed automatically from the width of the columns 12070 are computed automatically from the width of the columns
@@ -11764,12 +12167,14 @@ works you probably want to add it to `org-agenda-custom-commands' for good."
11764;;;###autoload 12167;;;###autoload
11765(defun org-store-link (arg) 12168(defun org-store-link (arg)
11766 "\\<org-mode-map>Store an org-link to the current location. 12169 "\\<org-mode-map>Store an org-link to the current location.
11767This link can later be inserted into an org-buffer with 12170This link is added to `org-stored-links' and can later be inserted
11768\\[org-insert-link]. 12171into an org-buffer with \\[org-insert-link].
12172
11769For some link types, a prefix arg is interpreted: 12173For some link types, a prefix arg is interpreted:
11770For links to usenet articles, arg negates `org-usenet-links-prefer-google'. 12174For links to usenet articles, arg negates `org-usenet-links-prefer-google'.
11771For file links, arg negates `org-context-in-file-links'." 12175For file links, arg negates `org-context-in-file-links'."
11772 (interactive "P") 12176 (interactive "P")
12177 (require 'org-irc)
11773 (setq org-store-link-plist nil) ; reset 12178 (setq org-store-link-plist nil) ; reset
11774 (let (link cpltxt desc description search txt) 12179 (let (link cpltxt desc description search txt)
11775 (cond 12180 (cond
@@ -11859,9 +12264,12 @@ For file links, arg negates `org-context-in-file-links'."
11859 (setq link (org-make-link "mhe:" (org-mhe-get-message-real-folder) "#" 12264 (setq link (org-make-link "mhe:" (org-mhe-get-message-real-folder) "#"
11860 (org-remove-angle-brackets message-id))))) 12265 (org-remove-angle-brackets message-id)))))
11861 12266
11862 ((eq major-mode 'rmail-mode) 12267 ((or (eq major-mode 'rmail-mode)
11863 (save-excursion 12268 (eq major-mode 'rmail-summary-mode))
12269 (save-window-excursion
11864 (save-restriction 12270 (save-restriction
12271 (when (eq major-mode 'rmail-summary-mode)
12272 (rmail-show-message rmail-current-message))
11865 (rmail-narrow-to-non-pruned-header) 12273 (rmail-narrow-to-non-pruned-header)
11866 (let ((folder buffer-file-name) 12274 (let ((folder buffer-file-name)
11867 (message-id (mail-fetch-field "message-id")) 12275 (message-id (mail-fetch-field "message-id"))
@@ -11873,7 +12281,8 @@ For file links, arg negates `org-context-in-file-links'."
11873 :subject subject :message-id message-id) 12281 :subject subject :message-id message-id)
11874 (setq message-id (org-remove-angle-brackets message-id)) 12282 (setq message-id (org-remove-angle-brackets message-id))
11875 (setq cpltxt (org-email-link-description)) 12283 (setq cpltxt (org-email-link-description))
11876 (setq link (org-make-link "rmail:" folder "#" message-id)))))) 12284 (setq link (org-make-link "rmail:" folder "#" message-id)))
12285 (rmail-show-message rmail-current-message))))
11877 12286
11878 ((eq major-mode 'gnus-group-mode) 12287 ((eq major-mode 'gnus-group-mode)
11879 (let ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus 12288 (let ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus
@@ -12311,7 +12720,6 @@ With three \\[universal-argument] prefixes, negate the meaning of
12311 (when (string-match "\\<file:\\(.*\\)" link) 12720 (when (string-match "\\<file:\\(.*\\)" link)
12312 (let* ((path (match-string 1 link)) 12721 (let* ((path (match-string 1 link))
12313 (origpath path) 12722 (origpath path)
12314 (desc-is-link (equal link desc))
12315 (case-fold-search nil)) 12723 (case-fold-search nil))
12316 (cond 12724 (cond
12317 ((eq org-link-file-path-type 'absolute) 12725 ((eq org-link-file-path-type 'absolute)
@@ -12421,192 +12829,193 @@ the end of the current subtree.
12421Normally, files will be opened by an appropriate application. If the 12829Normally, files will be opened by an appropriate application. If the
12422optional argument IN-EMACS is non-nil, Emacs will visit the file." 12830optional argument IN-EMACS is non-nil, Emacs will visit the file."
12423 (interactive "P") 12831 (interactive "P")
12424 (catch 'abort 12832 (require 'org-irc)
12425 (move-marker org-open-link-marker (point)) 12833 (move-marker org-open-link-marker (point))
12426 (setq org-window-config-before-follow-link (current-window-configuration)) 12834 (setq org-window-config-before-follow-link (current-window-configuration))
12427 (org-remove-occur-highlights nil nil t) 12835 (org-remove-occur-highlights nil nil t)
12428 (if (org-at-timestamp-p t) 12836 (if (org-at-timestamp-p t)
12429 (org-follow-timestamp-link) 12837 (org-follow-timestamp-link)
12430 (let (type path link line search (pos (point))) 12838 (let (type path link line search (pos (point)))
12431 (catch 'match 12839 (catch 'match
12432 (save-excursion 12840 (save-excursion
12433 (skip-chars-forward "^]\n\r") 12841 (skip-chars-forward "^]\n\r")
12434 (when (org-in-regexp org-bracket-link-regexp) 12842 (when (org-in-regexp org-bracket-link-regexp)
12435 (setq link (org-link-unescape (org-match-string-no-properties 1))) 12843 (setq link (org-link-unescape (org-match-string-no-properties 1)))
12436 (while (string-match " *\n *" link) 12844 (while (string-match " *\n *" link)
12437 (setq link (replace-match " " t t link))) 12845 (setq link (replace-match " " t t link)))
12438 (setq link (org-link-expand-abbrev link)) 12846 (setq link (org-link-expand-abbrev link))
12439 (if (string-match org-link-re-with-space2 link) 12847 (if (string-match org-link-re-with-space2 link)
12440 (setq type (match-string 1 link) path (match-string 2 link)) 12848 (setq type (match-string 1 link) path (match-string 2 link))
12441 (setq type "thisfile" path link)) 12849 (setq type "thisfile" path link))
12442 (throw 'match t))) 12850 (throw 'match t)))
12443 12851
12444 (when (get-text-property (point) 'org-linked-text) 12852 (when (get-text-property (point) 'org-linked-text)
12445 (setq type "thisfile" 12853 (setq type "thisfile"
12446 pos (if (get-text-property (1+ (point)) 'org-linked-text) 12854 pos (if (get-text-property (1+ (point)) 'org-linked-text)
12447 (1+ (point)) (point)) 12855 (1+ (point)) (point))
12448 path (buffer-substring 12856 path (buffer-substring
12449 (previous-single-property-change pos 'org-linked-text) 12857 (previous-single-property-change pos 'org-linked-text)
12450 (next-single-property-change pos 'org-linked-text))) 12858 (next-single-property-change pos 'org-linked-text)))
12451 (throw 'match t)) 12859 (throw 'match t))
12452 12860
12453 (save-excursion 12861 (save-excursion
12454 (when (or (org-in-regexp org-angle-link-re) 12862 (when (or (org-in-regexp org-angle-link-re)
12455 (org-in-regexp org-plain-link-re)) 12863 (org-in-regexp org-plain-link-re))
12456 (setq type (match-string 1) path (match-string 2)) 12864 (setq type (match-string 1) path (match-string 2))
12457 (throw 'match t))) 12865 (throw 'match t)))
12458 (when (org-in-regexp "\\<\\([^><\n]+\\)\\>") 12866 (when (org-in-regexp "\\<\\([^><\n]+\\)\\>")
12459 (setq type "tree-match" 12867 (setq type "tree-match"
12868 path (match-string 1))
12869 (throw 'match t))
12870 (save-excursion
12871 (when (org-in-regexp (org-re "\\(:[[:alnum:]_@:]+\\):[ \t]*$"))
12872 (setq type "tags"
12460 path (match-string 1)) 12873 path (match-string 1))
12461 (throw 'match t)) 12874 (while (string-match ":" path)
12462 (save-excursion 12875 (setq path (replace-match "+" t t path)))
12463 (when (org-in-regexp (org-re "\\(:[[:alnum:]_@:]+\\):[ \t]*$")) 12876 (throw 'match t))))
12464 (setq type "tags" 12877 (unless path
12465 path (match-string 1)) 12878 (error "No link found"))
12466 (while (string-match ":" path) 12879 ;; Remove any trailing spaces in path
12467 (setq path (replace-match "+" t t path))) 12880 (if (string-match " +\\'" path)
12468 (throw 'match t)))) 12881 (setq path (replace-match "" t t path)))
12469 (unless path
12470 (error "No link found"))
12471 ;; Remove any trailing spaces in path
12472 (if (string-match " +\\'" path)
12473 (setq path (replace-match "" t t path)))
12474 12882
12475 (cond 12883 (cond
12476 12884
12477 ((assoc type org-link-protocols) 12885 ((assoc type org-link-protocols)
12478 (funcall (nth 1 (assoc type org-link-protocols)) path)) 12886 (funcall (nth 1 (assoc type org-link-protocols)) path))
12479 12887
12480 ((equal type "mailto") 12888 ((equal type "mailto")
12481 (let ((cmd (car org-link-mailto-program)) 12889 (let ((cmd (car org-link-mailto-program))
12482 (args (cdr org-link-mailto-program)) args1 12890 (args (cdr org-link-mailto-program)) args1
12483 (address path) (subject "") a) 12891 (address path) (subject "") a)
12484 (if (string-match "\\(.*\\)::\\(.*\\)" path) 12892 (if (string-match "\\(.*\\)::\\(.*\\)" path)
12485 (setq address (match-string 1 path) 12893 (setq address (match-string 1 path)
12486 subject (org-link-escape (match-string 2 path)))) 12894 subject (org-link-escape (match-string 2 path))))
12487 (while args 12895 (while args
12488 (cond 12896 (cond
12489 ((not (stringp (car args))) (push (pop args) args1)) 12897 ((not (stringp (car args))) (push (pop args) args1))
12490 (t (setq a (pop args)) 12898 (t (setq a (pop args))
12491 (if (string-match "%a" a) 12899 (if (string-match "%a" a)
12492 (setq a (replace-match address t t a))) 12900 (setq a (replace-match address t t a)))
12493 (if (string-match "%s" a) 12901 (if (string-match "%s" a)
12494 (setq a (replace-match subject t t a))) 12902 (setq a (replace-match subject t t a)))
12495 (push a args1)))) 12903 (push a args1))))
12496 (apply cmd (nreverse args1)))) 12904 (apply cmd (nreverse args1))))
12497 12905
12498 ((member type '("http" "https" "ftp" "news")) 12906 ((member type '("http" "https" "ftp" "news"))
12499 (browse-url (concat type ":" (org-link-escape 12907 (browse-url (concat type ":" (org-link-escape
12500 path org-link-escape-chars-browser)))) 12908 path org-link-escape-chars-browser))))
12501 12909
12502 ((member type '("message")) 12910 ((member type '("message"))
12503 (browse-url (concat type ":" path))) 12911 (browse-url (concat type ":" path)))
12504 12912
12505 ((string= type "tags") 12913 ((string= type "tags")
12506 (org-tags-view in-emacs path)) 12914 (org-tags-view in-emacs path))
12507 ((string= type "thisfile") 12915 ((string= type "thisfile")
12508 (if in-emacs 12916 (if in-emacs
12509 (switch-to-buffer-other-window 12917 (switch-to-buffer-other-window
12510 (org-get-buffer-for-internal-link (current-buffer))) 12918 (org-get-buffer-for-internal-link (current-buffer)))
12511 (org-mark-ring-push)) 12919 (org-mark-ring-push))
12512 (let ((cmd `(org-link-search 12920 (let ((cmd `(org-link-search
12513 ,path 12921 ,path
12514 ,(cond ((equal in-emacs '(4)) 'occur) 12922 ,(cond ((equal in-emacs '(4)) 'occur)
12515 ((equal in-emacs '(16)) 'org-occur) 12923 ((equal in-emacs '(16)) 'org-occur)
12516 (t nil)) 12924 (t nil))
12517 ,pos))) 12925 ,pos)))
12518 (condition-case nil (eval cmd) 12926 (condition-case nil (eval cmd)
12519 (error (progn (widen) (eval cmd)))))) 12927 (error (progn (widen) (eval cmd))))))
12520 12928
12521 ((string= type "tree-match") 12929 ((string= type "tree-match")
12522 (org-occur (concat "\\[" (regexp-quote path) "\\]"))) 12930 (org-occur (concat "\\[" (regexp-quote path) "\\]")))
12523 12931
12524 ((string= type "file") 12932 ((string= type "file")
12525 (if (string-match "::\\([0-9]+\\)\\'" path) 12933 (if (string-match "::\\([0-9]+\\)\\'" path)
12526 (setq line (string-to-number (match-string 1 path)) 12934 (setq line (string-to-number (match-string 1 path))
12527 path (substring path 0 (match-beginning 0))) 12935 path (substring path 0 (match-beginning 0)))
12528 (if (string-match "::\\(.+\\)\\'" path) 12936 (if (string-match "::\\(.+\\)\\'" path)
12529 (setq search (match-string 1 path) 12937 (setq search (match-string 1 path)
12530 path (substring path 0 (match-beginning 0))))) 12938 path (substring path 0 (match-beginning 0)))))
12531 (if (string-match "[*?{]" (file-name-nondirectory path)) 12939 (if (string-match "[*?{]" (file-name-nondirectory path))
12532 (dired path) 12940 (dired path)
12533 (org-open-file path in-emacs line search))) 12941 (org-open-file path in-emacs line search)))
12534 12942
12535 ((string= type "news") 12943 ((string= type "news")
12536 (org-follow-gnus-link path)) 12944 (org-follow-gnus-link path))
12537 12945
12538 ((string= type "bbdb") 12946 ((string= type "bbdb")
12539 (org-follow-bbdb-link path)) 12947 (org-follow-bbdb-link path))
12540 12948
12541 ((string= type "info") 12949 ((string= type "info")
12542 (org-follow-info-link path)) 12950 (org-follow-info-link path))
12543 12951
12544 ((string= type "gnus") 12952 ((string= type "gnus")
12545 (let (group article) 12953 (let (group article)
12546 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)) 12954 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
12547 (error "Error in Gnus link")) 12955 (error "Error in Gnus link"))
12548 (setq group (match-string 1 path) 12956 (setq group (match-string 1 path)
12549 article (match-string 3 path)) 12957 article (match-string 3 path))
12550 (org-follow-gnus-link group article))) 12958 (org-follow-gnus-link group article)))
12551 12959
12552 ((string= type "vm") 12960 ((string= type "vm")
12553 (let (folder article) 12961 (let (folder article)
12554 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)) 12962 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
12555 (error "Error in VM link")) 12963 (error "Error in VM link"))
12556 (setq folder (match-string 1 path) 12964 (setq folder (match-string 1 path)
12557 article (match-string 3 path)) 12965 article (match-string 3 path))
12558 ;; in-emacs is the prefix arg, will be interpreted as read-only 12966 ;; in-emacs is the prefix arg, will be interpreted as read-only
12559 (org-follow-vm-link folder article in-emacs))) 12967 (org-follow-vm-link folder article in-emacs)))
12560 12968
12561 ((string= type "wl") 12969 ((string= type "wl")
12562 (let (folder article) 12970 (let (folder article)
12563 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)) 12971 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
12564 (error "Error in Wanderlust link")) 12972 (error "Error in Wanderlust link"))
12565 (setq folder (match-string 1 path) 12973 (setq folder (match-string 1 path)
12566 article (match-string 3 path)) 12974 article (match-string 3 path))
12567 (org-follow-wl-link folder article))) 12975 (org-follow-wl-link folder article)))
12568 12976
12569 ((string= type "mhe") 12977 ((string= type "mhe")
12570 (let (folder article) 12978 (let (folder article)
12571 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)) 12979 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
12572 (error "Error in MHE link")) 12980 (error "Error in MHE link"))
12573 (setq folder (match-string 1 path) 12981 (setq folder (match-string 1 path)
12574 article (match-string 3 path)) 12982 article (match-string 3 path))
12575 (org-follow-mhe-link folder article))) 12983 (org-follow-mhe-link folder article)))
12576 12984
12577 ((string= type "rmail") 12985 ((string= type "rmail")
12578 (let (folder article) 12986 (let (folder article)
12579 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)) 12987 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
12580 (error "Error in RMAIL link")) 12988 (error "Error in RMAIL link"))
12581 (setq folder (match-string 1 path) 12989 (setq folder (match-string 1 path)
12582 article (match-string 3 path)) 12990 article (match-string 3 path))
12583 (org-follow-rmail-link folder article))) 12991 (org-follow-rmail-link folder article)))
12584 12992
12585 ((string= type "shell") 12993 ((string= type "shell")
12586 (let ((cmd path)) 12994 (let ((cmd path))
12587 (if (or (not org-confirm-shell-link-function) 12995 (if (or (not org-confirm-shell-link-function)
12588 (funcall org-confirm-shell-link-function 12996 (funcall org-confirm-shell-link-function
12589 (format "Execute \"%s\" in shell? " 12997 (format "Execute \"%s\" in shell? "
12590 (org-add-props cmd nil 12998 (org-add-props cmd nil
12591 'face 'org-warning)))) 12999 'face 'org-warning))))
12592 (progn 13000 (progn
12593 (message "Executing %s" cmd) 13001 (message "Executing %s" cmd)
12594 (shell-command cmd)) 13002 (shell-command cmd))
12595 (error "Abort")))) 13003 (error "Abort"))))
12596 13004
12597 ((string= type "elisp") 13005 ((string= type "elisp")
12598 (let ((cmd path)) 13006 (let ((cmd path))
12599 (if (or (not org-confirm-elisp-link-function) 13007 (if (or (not org-confirm-elisp-link-function)
12600 (funcall org-confirm-elisp-link-function 13008 (funcall org-confirm-elisp-link-function
12601 (format "Execute \"%s\" as elisp? " 13009 (format "Execute \"%s\" as elisp? "
12602 (org-add-props cmd nil 13010 (org-add-props cmd nil
12603 'face 'org-warning)))) 13011 'face 'org-warning))))
12604 (message "%s => %s" cmd (eval (read cmd))) 13012 (message "%s => %s" cmd (eval (read cmd)))
12605 (error "Abort")))) 13013 (error "Abort"))))
12606 13014
12607 (t 13015 (t
12608 (browse-url-at-point))))) 13016 (browse-url-at-point)))))
12609 (move-marker org-open-link-marker nil))) 13017 (move-marker org-open-link-marker nil)
13018 (run-hook-with-args 'org-follow-link-hook))
12610 13019
12611;;; File search 13020;;; File search
12612 13021
@@ -13197,7 +13606,9 @@ If the file does not exist, an error is thrown."
13197 (while (string-match "['\"]%s['\"]" cmd) 13606 (while (string-match "['\"]%s['\"]" cmd)
13198 (setq cmd (replace-match "%s" t t cmd))) 13607 (setq cmd (replace-match "%s" t t cmd)))
13199 (while (string-match "%s" cmd) 13608 (while (string-match "%s" cmd)
13200 (setq cmd (replace-match (shell-quote-argument file) t t cmd))) 13609 (setq cmd (replace-match
13610 (save-match-data (shell-quote-argument file))
13611 t t cmd)))
13201 (save-window-excursion 13612 (save-window-excursion
13202 (start-process-shell-command cmd nil cmd))) 13613 (start-process-shell-command cmd nil cmd)))
13203 ((or (stringp cmd) 13614 ((or (stringp cmd)
@@ -13271,13 +13682,44 @@ RET at beg-of-buf -> Append to file as level 2 headline
13271(defvar org-remember-previous-location nil) 13682(defvar org-remember-previous-location nil)
13272(defvar org-force-remember-template-char) ;; dynamically scoped 13683(defvar org-force-remember-template-char) ;; dynamically scoped
13273 13684
13685;; Save the major mode of the buffer we called remember from
13686(defvar org-select-template-temp-major-mode nil)
13687
13688;; Temporary store the buffer where remember was called from
13689(defvar org-select-template-original-buffer nil)
13690
13274(defun org-select-remember-template (&optional use-char) 13691(defun org-select-remember-template (&optional use-char)
13275 (when org-remember-templates 13692 (when org-remember-templates
13276 (let* ((templates (mapcar (lambda (x) 13693 (let* ((pre-selected-templates
13694 (mapcar
13695 (lambda (tpl)
13696 (let ((ctxt (nth 5 tpl))
13697 (mode org-select-template-temp-major-mode)
13698 (buf org-select-template-original-buffer))
13699 (and (or (not ctxt) (eq ctxt t)
13700 (and (listp ctxt) (memq mode ctxt))
13701 (and (functionp ctxt)
13702 (with-current-buffer buf
13703 ;; Protect the user-defined function from error
13704 (condition-case nil (funcall ctxt) (error nil)))))
13705 tpl)))
13706 org-remember-templates))
13707 ;; If no template at this point, add the default templates:
13708 (pre-selected-templates1
13709 (if (not (delq nil pre-selected-templates))
13710 (mapcar (lambda(x) (if (not (nth 5 x)) x))
13711 org-remember-templates)
13712 pre-selected-templates))
13713 ;; Then unconditionnally add template for any contexts
13714 (pre-selected-templates2
13715 (append (mapcar (lambda(x) (if (eq (nth 5 x) t) x))
13716 org-remember-templates)
13717 (delq nil pre-selected-templates1)))
13718 (templates (mapcar (lambda (x)
13277 (if (stringp (car x)) 13719 (if (stringp (car x))
13278 (append (list (nth 1 x) (car x)) (cddr x)) 13720 (append (list (nth 1 x) (car x)) (cddr x))
13279 (append (list (car x) "") (cdr x)))) 13721 (append (list (car x) "") (cdr x))))
13280 org-remember-templates)) 13722 (delq nil pre-selected-templates2)))
13281 (char (or use-char 13723 (char (or use-char
13282 (cond 13724 (cond
13283 ((= (length templates) 1) 13725 ((= (length templates) 1)
@@ -13315,8 +13757,6 @@ RET at beg-of-buf -> Append to file as level 2 headline
13315 "Initialize *remember* buffer with template, invoke `org-mode'. 13757 "Initialize *remember* buffer with template, invoke `org-mode'.
13316This function should be placed into `remember-mode-hook' and in fact requires 13758This function should be placed into `remember-mode-hook' and in fact requires
13317to be run from that hook to function properly." 13759to be run from that hook to function properly."
13318 (unless (fboundp 'remember-finalize)
13319 (defalias 'remember-finalize 'remember-buffer))
13320 (if org-remember-templates 13760 (if org-remember-templates
13321 (let* ((entry (org-select-remember-template use-char)) 13761 (let* ((entry (org-select-remember-template use-char))
13322 (tpl (car entry)) 13762 (tpl (car entry))
@@ -13416,14 +13856,14 @@ to be run from that hook to function properly."
13416 13856
13417 ;; Turn on org-mode in the remember buffer, set local variables 13857 ;; Turn on org-mode in the remember buffer, set local variables
13418 (org-mode) 13858 (org-mode)
13419 (org-set-local 'org-finish-function 'remember-finalize) 13859 (org-set-local 'org-finish-function 'org-remember-finalize)
13420 (if (and file (string-match "\\S-" file) (not (file-directory-p file))) 13860 (if (and file (string-match "\\S-" file) (not (file-directory-p file)))
13421 (org-set-local 'org-default-notes-file file)) 13861 (org-set-local 'org-default-notes-file file))
13422 (if (and headline (stringp headline) (string-match "\\S-" headline)) 13862 (if (and headline (stringp headline) (string-match "\\S-" headline))
13423 (org-set-local 'org-remember-default-headline headline)) 13863 (org-set-local 'org-remember-default-headline headline))
13424 ;; Interactive template entries 13864 ;; Interactive template entries
13425 (goto-char (point-min)) 13865 (goto-char (point-min))
13426 (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([guUtT]\\)?" nil t) 13866 (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGuUtT]\\)?" nil t)
13427 (setq char (if (match-end 3) (match-string 3)) 13867 (setq char (if (match-end 3) (match-string 3))
13428 prompt (if (match-end 2) (match-string 2))) 13868 prompt (if (match-end 2) (match-string 2)))
13429 (goto-char (match-beginning 0)) 13869 (goto-char (match-beginning 0))
@@ -13448,7 +13888,7 @@ to be run from that hook to function properly."
13448 'org-tags-completion-function nil nil nil 13888 'org-tags-completion-function nil nil nil
13449 'org-tags-history))) 13889 'org-tags-history)))
13450 (setq ins (mapconcat 'identity 13890 (setq ins (mapconcat 'identity
13451 (org-split-string ins (org-re "[^[:alnum:]]+")) 13891 (org-split-string ins (org-re "[^[:alnum:]_@]+"))
13452 ":")) 13892 ":"))
13453 (when (string-match "\\S-" ins) 13893 (when (string-match "\\S-" ins)
13454 (or (equal (char-before) ?:) (insert ":")) 13894 (or (equal (char-before) ?:) (insert ":"))
@@ -13472,7 +13912,7 @@ to be run from that hook to function properly."
13472 (replace-match "") 13912 (replace-match "")
13473 (and (re-search-forward "^[^#\n]" nil t) (backward-char 1)))) 13913 (and (re-search-forward "^[^#\n]" nil t) (backward-char 1))))
13474 (org-mode) 13914 (org-mode)
13475 (org-set-local 'org-finish-function 'remember-finalize)) 13915 (org-set-local 'org-finish-function 'org-remember-finalize))
13476 (when (save-excursion 13916 (when (save-excursion
13477 (goto-char (point-min)) 13917 (goto-char (point-min))
13478 (re-search-forward "%!" nil t)) 13918 (re-search-forward "%!" nil t))
@@ -13487,6 +13927,19 @@ from that hook."
13487 (when org-finish-function 13927 (when org-finish-function
13488 (funcall org-finish-function))) 13928 (funcall org-finish-function)))
13489 13929
13930(defvar org-clock-marker) ; Defined below
13931(defun org-remember-finalize ()
13932 "Finalize the remember process."
13933 (unless (fboundp 'remember-finalize)
13934 (defalias 'remember-finalize 'remember-buffer))
13935 (when (and org-clock-marker
13936 (equal (marker-buffer org-clock-marker) (current-buffer)))
13937 ;; FIXME: test this, this is w/o notetaking!
13938 (let (org-log-note-clock-out) (org-clock-out)))
13939 (when buffer-file-name
13940 (save-buffer)
13941 (setq buffer-file-name nil))
13942 (remember-finalize))
13490 13943
13491;;;###autoload 13944;;;###autoload
13492(defun org-remember (&optional goto org-force-remember-template-char) 13945(defun org-remember (&optional goto org-force-remember-template-char)
@@ -13506,6 +13959,10 @@ associated with a template in `org-remember-templates'."
13506 ((equal goto '(4)) (org-go-to-remember-target)) 13959 ((equal goto '(4)) (org-go-to-remember-target))
13507 ((equal goto '(16)) (org-remember-goto-last-stored)) 13960 ((equal goto '(16)) (org-remember-goto-last-stored))
13508 (t 13961 (t
13962 ;; set temporary variables that will be needed in
13963 ;; `org-select-remember-template'
13964 (setq org-select-template-temp-major-mode major-mode)
13965 (setq org-select-template-original-buffer (current-buffer))
13509 (if (memq org-finish-function '(remember-buffer remember-finalize)) 13966 (if (memq org-finish-function '(remember-buffer remember-finalize))
13510 (progn 13967 (progn
13511 (when (< (length org-remember-templates) 2) 13968 (when (< (length org-remember-templates) 2)
@@ -13529,7 +13986,8 @@ associated with a template in `org-remember-templates'."
13529 "Go to the target location of a remember template. 13986 "Go to the target location of a remember template.
13530The user is queried for the template." 13987The user is queried for the template."
13531 (interactive) 13988 (interactive)
13532 (let* ((entry (org-select-remember-template template-key)) 13989 (let* (org-select-template-temp-major-mode
13990 (entry (org-select-remember-template template-key))
13533 (file (nth 1 entry)) 13991 (file (nth 1 entry))
13534 (heading (nth 2 entry)) 13992 (heading (nth 2 entry))
13535 visiting) 13993 visiting)
@@ -13602,10 +14060,12 @@ See also the variable `org-reverse-note-order'."
13602 org-remember-store-without-prompt)) 14060 org-remember-store-without-prompt))
13603 (file (cond 14061 (file (cond
13604 (fastp org-default-notes-file) 14062 (fastp org-default-notes-file)
13605 ((and org-remember-use-refile-when-interactive 14063 ((and (eq org-remember-interactive-interface 'refile)
13606 org-refile-targets) 14064 org-refile-targets)
13607 org-default-notes-file) 14065 org-default-notes-file)
13608 (t (org-get-org-file)))) 14066 ((not (and (equal current-prefix-arg '(16))
14067 org-remember-previous-location))
14068 (org-get-org-file))))
13609 (heading org-remember-default-headline) 14069 (heading org-remember-default-headline)
13610 (visiting (and file (org-find-base-buffer-visiting file))) 14070 (visiting (and file (org-find-base-buffer-visiting file)))
13611 (org-startup-folded nil) 14071 (org-startup-folded nil)
@@ -13648,7 +14108,7 @@ See also the variable `org-reverse-note-order'."
13648 (erase-buffer) 14108 (erase-buffer)
13649 (insert txt) 14109 (insert txt)
13650 (goto-char (point-min)) 14110 (goto-char (point-min))
13651 (when (and org-remember-use-refile-when-interactive 14111 (when (and (eq org-remember-interactive-interface 'refile)
13652 (not fastp)) 14112 (not fastp))
13653 (org-refile nil (or visiting (find-file-noselect file))) 14113 (org-refile nil (or visiting (find-file-noselect file)))
13654 (throw 'quit t)) 14114 (throw 'quit t))
@@ -13679,13 +14139,22 @@ See also the variable `org-reverse-note-order'."
13679 (insert "* " heading "\n") 14139 (insert "* " heading "\n")
13680 (setq org-goto-start-pos (point-at-bol 0))))) 14140 (setq org-goto-start-pos (point-at-bol 0)))))
13681 14141
13682 ;; Ask the User for a location 14142 ;; Ask the User for a location, using the appropriate interface
13683 (if fastp 14143 (cond
13684 (setq spos org-goto-start-pos 14144 (fastp (setq spos org-goto-start-pos
13685 exitcmd 'return) 14145 exitcmd 'return))
13686 (setq spos (org-get-location (current-buffer) org-remember-help) 14146 ((eq org-remember-interactive-interface 'outline)
14147 (setq spos (org-get-location (current-buffer)
14148 org-remember-help)
13687 exitcmd (cdr spos) 14149 exitcmd (cdr spos)
13688 spos (car spos))) 14150 spos (car spos)))
14151 ((eq org-remember-interactive-interface 'outline-path-completion)
14152 (let ((org-refile-targets '((nil . (:maxlevel . 10))))
14153 (org-refile-use-outline-path t))
14154 (setq spos (org-refile-get-location "Heading: ")
14155 exitcmd 'return
14156 spos (nth 3 spos))))
14157 (t (error "this should not hapen")))
13689 (if (not spos) (throw 'quit nil)) ; return nil to show we did 14158 (if (not spos) (throw 'quit nil)) ; return nil to show we did
13690 ; not handle this note 14159 ; not handle this note
13691 (goto-char spos) 14160 (goto-char spos)
@@ -13782,7 +14251,7 @@ See also the variable `org-reverse-note-order'."
13782(defun org-get-refile-targets (&optional default-buffer) 14251(defun org-get-refile-targets (&optional default-buffer)
13783 "Produce a table with refile targets." 14252 "Produce a table with refile targets."
13784 (let ((entries (or org-refile-targets '((nil . (:level . 1))))) 14253 (let ((entries (or org-refile-targets '((nil . (:level . 1)))))
13785 org-agenda-new-buffers targets txt re files f desc descre) 14254 targets txt re files f desc descre)
13786 (with-current-buffer (or default-buffer (current-buffer)) 14255 (with-current-buffer (or default-buffer (current-buffer))
13787 (while (setq entry (pop entries)) 14256 (while (setq entry (pop entries))
13788 (setq files (car entry) desc (cdr entry)) 14257 (setq files (car entry) desc (cdr entry))
@@ -13847,10 +14316,10 @@ See also the variable `org-reverse-note-order'."
13847 "/"))) 14316 "/")))
13848 (push (list txt f re (point)) targets)) 14317 (push (list txt f re (point)) targets))
13849 (goto-char (point-at-eol)))))))) 14318 (goto-char (point-at-eol))))))))
13850 (org-release-buffers org-agenda-new-buffers)
13851 (nreverse targets)))) 14319 (nreverse targets))))
13852 14320
13853(defun org-get-outline-path () 14321(defun org-get-outline-path ()
14322 "Return the outline path to the current entry, as a list."
13854 (let (rtn) 14323 (let (rtn)
13855 (save-excursion 14324 (save-excursion
13856 (while (org-up-heading-safe) 14325 (while (org-up-heading-safe)
@@ -13861,7 +14330,7 @@ See also the variable `org-reverse-note-order'."
13861(defvar org-refile-history nil 14330(defvar org-refile-history nil
13862 "History for refiling operations.") 14331 "History for refiling operations.")
13863 14332
13864(defun org-refile (&optional reversed-or-update default-buffer) 14333(defun org-refile (&optional goto default-buffer)
13865 "Move the entry at point to another heading. 14334 "Move the entry at point to another heading.
13866The list of target headings is compiled using the information in 14335The list of target headings is compiled using the information in
13867`org-refile-targets', which see. This list is created upon first use, and 14336`org-refile-targets', which see. This list is created upon first use, and
@@ -13870,60 +14339,82 @@ FIXME: Can we find a better way of updating?
13870 14339
13871At the target location, the entry is filed as a subitem of the target heading. 14340At the target location, the entry is filed as a subitem of the target heading.
13872Depending on `org-reverse-note-order', the new subitem will either be the 14341Depending on `org-reverse-note-order', the new subitem will either be the
13873first of the last subitem. A single C-u prefix will toggle the value of this 14342first of the last subitem.
13874variable for the duration of the command." 14343
14344With prefix arg GOTO, the command will only visit the target location,
14345not actually move anything.
14346With a double prefix `C-c C-c', go to the location where the last refiling
14347operation has put the subtree.
14348
14349With a double prefix argument, the command can be used to jump to any
14350heading in the current buffer."
13875 (interactive "P") 14351 (interactive "P")
13876 (if (equal reversed-or-update '(16)) 14352 (let* ((cbuf (current-buffer))
13877 (progn 14353 (filename (buffer-file-name (buffer-base-buffer cbuf)))
13878 (setq org-refile-target-table (org-get-refile-targets default-buffer)) 14354 pos it nbuf file re level reversed)
13879 (message "Refile targets updated (%d targets)" 14355 (if (equal goto '(16))
13880 (length org-refile-target-table))) 14356 (org-refile-goto-last-stored)
13881 (when (or (not org-refile-target-table) 14357 (when (setq it (org-refile-get-location
13882 (assq nil org-refile-targets)) 14358 (if goto "Goto: " "Refile to: ") default-buffer))
13883 (setq org-refile-target-table (org-get-refile-targets default-buffer))) 14359 (setq file (nth 1 it)
13884 (unless org-refile-target-table 14360 re (nth 2 it)
13885 (error "No refile targets")) 14361 pos (nth 3 it))
13886 (let* ((cbuf (current-buffer)) 14362 (setq nbuf (or (find-buffer-visiting file)
13887 (filename (buffer-file-name (buffer-base-buffer cbuf))) 14363 (find-file-noselect file)))
13888 (fname (and filename (file-truename filename))) 14364 (if goto
13889 (tbl (mapcar 14365 (progn
13890 (lambda (x) 14366 (switch-to-buffer nbuf)
13891 (if (not (equal fname (file-truename (nth 1 x)))) 14367 (goto-char pos)
13892 (cons (concat (car x) " (" (file-name-nondirectory 14368 (org-show-context 'org-goto))
13893 (nth 1 x)) ")") 14369 (org-copy-special)
13894 (cdr x))
13895 x))
13896 org-refile-target-table))
13897 (completion-ignore-case t)
13898 pos it nbuf file re level reversed)
13899 (when (setq it (completing-read "Refile to: " tbl
13900 nil t nil 'org-refile-history))
13901 (setq it (assoc it tbl)
13902 file (nth 1 it)
13903 re (nth 2 it))
13904 (org-copy-special)
13905 (save-excursion
13906 (set-buffer (setq nbuf (or (find-buffer-visiting file)
13907 (find-file-noselect file))))
13908 (setq reversed (org-notes-order-reversed-p))
13909 (if (equal reversed-or-update '(16)) (setq reversed (not reversed)))
13910 (save-excursion 14370 (save-excursion
13911 (save-restriction 14371 (set-buffer (setq nbuf (or (find-buffer-visiting file)
13912 (widen) 14372 (find-file-noselect file))))
13913 (goto-char (point-min)) 14373 (setq reversed (org-notes-order-reversed-p))
13914 (unless (re-search-forward re nil t) 14374 (save-excursion
13915 (error "Cannot find target location - try again with `C-u' prefix.")) 14375 (save-restriction
13916 (goto-char (match-beginning 0)) 14376 (widen)
13917 (looking-at outline-regexp) 14377 (goto-char pos)
13918 (setq level (org-get-valid-level (funcall outline-level) 1)) 14378 (looking-at outline-regexp)
13919 (goto-char (or (save-excursion 14379 (setq level (org-get-valid-level (funcall outline-level) 1))
13920 (if reversed 14380 (goto-char
13921 (outline-next-heading) 14381 (if reversed
13922 (outline-get-next-sibling))) 14382 (outline-next-heading)
13923 (point-max))) 14383 (or (save-excursion (outline-get-next-sibling))
13924 (org-paste-subtree level)))) 14384 (org-end-of-subtree t t)
13925 (org-cut-special) 14385 (point-max))))
13926 (message "Entry refiled to \"%s\"" (car it)))))) 14386 (bookmark-set "org-refile-last-stored")
14387 (org-paste-subtree level))))
14388 (org-cut-special)
14389 (message "Entry refiled to \"%s\"" (car it)))))))
14390
14391(defun org-refile-goto-last-stored ()
14392 "Go to the location where the last refile was stored."
14393 (interactive)
14394 (bookmark-jump "org-refile-last-stored")
14395 (message "This is the location of the last refile"))
14396
14397(defun org-refile-get-location (&optional prompt default-buffer)
14398 "Prompt the user for a refile location, using PROMPT."
14399 (let ((org-refile-targets org-refile-targets)
14400 (org-refile-use-outline-path org-refile-use-outline-path))
14401 (setq org-refile-target-table (org-get-refile-targets default-buffer)))
14402 (unless org-refile-target-table
14403 (error "No refile targets"))
14404 (let* ((cbuf (current-buffer))
14405 (filename (buffer-file-name (buffer-base-buffer cbuf)))
14406 (fname (and filename (file-truename filename)))
14407 (tbl (mapcar
14408 (lambda (x)
14409 (if (not (equal fname (file-truename (nth 1 x))))
14410 (cons (concat (car x) " (" (file-name-nondirectory
14411 (nth 1 x)) ")")
14412 (cdr x))
14413 x))
14414 org-refile-target-table))
14415 (completion-ignore-case t))
14416 (assoc (completing-read prompt tbl nil t nil 'org-refile-history)
14417 tbl)))
13927 14418
13928;;;; Dynamic blocks 14419;;;; Dynamic blocks
13929 14420
@@ -13971,6 +14462,10 @@ the property list including an extra property :name with the block name."
13971 (read (concat "(" (match-string 3) ")"))))) 14462 (read (concat "(" (match-string 3) ")")))))
13972 (unless (re-search-forward org-dblock-end-re nil t) 14463 (unless (re-search-forward org-dblock-end-re nil t)
13973 (error "Dynamic block not terminated")) 14464 (error "Dynamic block not terminated"))
14465 (setq params
14466 (append params
14467 (list :content (buffer-substring
14468 begdel (match-beginning 0)))))
13974 (delete-region begdel (match-beginning 0)) 14469 (delete-region begdel (match-beginning 0))
13975 (goto-char begdel) 14470 (goto-char begdel)
13976 (open-line 1) 14471 (open-line 1)
@@ -14118,7 +14613,7 @@ At all other locations, this simply calls the value of
14118 (tag (setq type :tag beg beg1) 14613 (tag (setq type :tag beg beg1)
14119 (or org-tag-alist (org-get-buffer-tags))) 14614 (or org-tag-alist (org-get-buffer-tags)))
14120 (prop (setq type :prop beg beg1) 14615 (prop (setq type :prop beg beg1)
14121 (mapcar 'list (org-buffer-property-keys))) 14616 (mapcar 'list (org-buffer-property-keys nil t t)))
14122 (t (progn 14617 (t (progn
14123 (call-interactively org-completion-fallback-command) 14618 (call-interactively org-completion-fallback-command)
14124 (throw 'exit nil))))) 14619 (throw 'exit nil)))))
@@ -14274,8 +14769,9 @@ For calling through lisp, arg is also interpreted in the following way:
14274 (let* ((match-data (match-data)) 14769 (let* ((match-data (match-data))
14275 (startpos (point-at-bol)) 14770 (startpos (point-at-bol))
14276 (logging (save-match-data (org-entry-get nil "LOGGING" t))) 14771 (logging (save-match-data (org-entry-get nil "LOGGING" t)))
14277 (org-log-done (org-parse-local-options logging 'org-log-done)) 14772 (org-log-done org-log-done)
14278 (org-log-repeat (org-parse-local-options logging 'org-log-repeat)) 14773 (org-log-repeat org-log-repeat)
14774 (org-todo-log-states org-todo-log-states)
14279 (this (match-string 1)) 14775 (this (match-string 1))
14280 (hl-pos (match-beginning 0)) 14776 (hl-pos (match-beginning 0))
14281 (head (org-get-todo-sequence-head this)) 14777 (head (org-get-todo-sequence-head this))
@@ -14345,7 +14841,7 @@ For calling through lisp, arg is also interpreted in the following way:
14345 (next (if state (concat " " state " ") " ")) 14841 (next (if state (concat " " state " ") " "))
14346 (change-plist (list :type 'todo-state-change :from this :to state 14842 (change-plist (list :type 'todo-state-change :from this :to state
14347 :position startpos)) 14843 :position startpos))
14348 dostates) 14844 dolog now-done-p)
14349 (when org-blocker-hook 14845 (when org-blocker-hook
14350 (unless (save-excursion 14846 (unless (save-excursion
14351 (save-match-data 14847 (save-match-data
@@ -14374,33 +14870,36 @@ For calling through lisp, arg is also interpreted in the following way:
14374 (mapconcat 'identity (assoc state org-todo-sets) " "))) 14870 (mapconcat 'identity (assoc state org-todo-sets) " ")))
14375 (setq org-last-todo-state-is-todo 14871 (setq org-last-todo-state-is-todo
14376 (not (member state org-done-keywords))) 14872 (not (member state org-done-keywords)))
14377 (when (and org-log-done (not (memq arg '(nextset previousset)))) 14873 (setq now-done-p (and (member state org-done-keywords)
14378 (setq dostates (and (listp org-log-done) (memq 'state org-log-done) 14874 (not (member this org-done-keywords))))
14379 (or (not org-todo-log-states) 14875 (and logging (org-local-logging logging))
14380 (member state org-todo-log-states)))) 14876 (when (and (or org-todo-log-states org-log-done)
14381 14877 (not (memq arg '(nextset previousset))))
14382 (cond 14878 ;; we need to look at recording a time and note
14383 ((and state (member state org-not-done-keywords) 14879 (setq dolog (or (nth 1 (assoc state org-todo-log-states))
14384 (not (member this org-not-done-keywords))) 14880 (nth 2 (assoc this org-todo-log-states))))
14881 (when (and state
14882 (member state org-not-done-keywords)
14883 (not (member this org-not-done-keywords)))
14385 ;; This is now a todo state and was not one before 14884 ;; This is now a todo state and was not one before
14386 ;; Remove any CLOSED timestamp, and possibly log the state change 14885 ;; If there was a CLOSED time stamp, get rid of it.
14387 (org-add-planning-info nil nil 'closed) 14886 (org-add-planning-info nil nil 'closed))
14388 (and dostates (org-add-log-maybe 'state state 'findpos))) 14887 (when (and now-done-p org-log-done)
14389 ((and state dostates)
14390 ;; This is a non-nil state, and we need to log it
14391 (org-add-log-maybe 'state state 'findpos))
14392 ((and (member state org-done-keywords)
14393 (not (member this org-done-keywords)))
14394 ;; It is now done, and it was not done before 14888 ;; It is now done, and it was not done before
14395 (org-add-planning-info 'closed (org-current-time)) 14889 (org-add-planning-info 'closed (org-current-time))
14396 (org-add-log-maybe 'done state 'findpos)))) 14890 (if (and (not dolog) (eq 'note org-log-done))
14891 (org-add-log-maybe 'done state 'findpos 'note)))
14892 (when (and state dolog)
14893 ;; This is a non-nil state, and we need to log it
14894 (org-add-log-maybe 'state state 'findpos dolog)))
14397 ;; Fixup tag positioning 14895 ;; Fixup tag positioning
14398 (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t)) 14896 (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t))
14399 (run-hooks 'org-after-todo-state-change-hook) 14897 (run-hooks 'org-after-todo-state-change-hook)
14400 (and (member state org-done-keywords) (org-auto-repeat-maybe))
14401 (if (and arg (not (member state org-done-keywords))) 14898 (if (and arg (not (member state org-done-keywords)))
14402 (setq head (org-get-todo-sequence-head state))) 14899 (setq head (org-get-todo-sequence-head state)))
14403 (put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head) 14900 (put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head)
14901 ;; Do we need to trigger a repeat?
14902 (when now-done-p (org-auto-repeat-maybe state))
14404 ;; Fixup cursor location if close to the keyword 14903 ;; Fixup cursor location if close to the keyword
14405 (if (and (outline-on-heading-p) 14904 (if (and (outline-on-heading-p)
14406 (not (bolp)) 14905 (not (bolp))
@@ -14414,6 +14913,23 @@ For calling through lisp, arg is also interpreted in the following way:
14414 (save-excursion 14913 (save-excursion
14415 (run-hook-with-args 'org-trigger-hook change-plist))))))) 14914 (run-hook-with-args 'org-trigger-hook change-plist)))))))
14416 14915
14916(defun org-local-logging (value)
14917 "Get logging settings from a property VALUE."
14918 (let* (words w a)
14919 ;; directly set the variables, they are already local.
14920 (setq org-log-done nil
14921 org-log-repeat nil
14922 org-todo-log-states nil)
14923 (setq words (org-split-string value))
14924 (while (setq w (pop words))
14925 (cond
14926 ((setq a (assoc w org-startup-options))
14927 (and (member (nth 1 a) '(org-log-done org-log-repeat))
14928 (set (nth 1 a) (nth 2 a))))
14929 ((setq a (org-extract-log-state-settings w))
14930 (and (member (car a) org-todo-keywords-1)
14931 (push a org-todo-log-states)))))))
14932
14417(defun org-get-todo-sequence-head (kwd) 14933(defun org-get-todo-sequence-head (kwd)
14418 "Return the head of the TODO sequence to which KWD belongs. 14934 "Return the head of the TODO sequence to which KWD belongs.
14419If KWD is not set, check if there is a text property remembering the 14935If KWD is not set, check if there is a text property remembering the
@@ -14500,44 +15016,74 @@ Returns the new TODO keyword, or nil if no state change should occur."
14500 15016
14501(defvar org-last-changed-timestamp) 15017(defvar org-last-changed-timestamp)
14502(defvar org-log-post-message) 15018(defvar org-log-post-message)
14503(defun org-auto-repeat-maybe () 15019(defvar org-log-note-purpose)
15020(defun org-auto-repeat-maybe (done-word)
14504 "Check if the current headline contains a repeated deadline/schedule. 15021 "Check if the current headline contains a repeated deadline/schedule.
14505If yes, set TODO state back to what it was and change the base date 15022If yes, set TODO state back to what it was and change the base date
14506of repeating deadline/scheduled time stamps to new date. 15023of repeating deadline/scheduled time stamps to new date.
14507This function should be run in the `org-after-todo-state-change-hook'." 15024This function is run automatically after each state change to a DONE state."
14508 ;; last-state is dynamically scoped into this function 15025 ;; last-state is dynamically scoped into this function
14509 (let* ((repeat (org-get-repeat)) 15026 (let* ((repeat (org-get-repeat))
14510 (aa (assoc last-state org-todo-kwd-alist)) 15027 (aa (assoc last-state org-todo-kwd-alist))
14511 (interpret (nth 1 aa)) 15028 (interpret (nth 1 aa))
14512 (head (nth 2 aa)) 15029 (head (nth 2 aa))
14513 (done-word (nth 3 aa))
14514 (whata '(("d" . day) ("m" . month) ("y" . year))) 15030 (whata '(("d" . day) ("m" . month) ("y" . year)))
14515 (msg "Entry repeats: ") 15031 (msg "Entry repeats: ")
14516 (org-log-done) 15032 (org-log-done nil)
14517 re type n what ts) 15033 (org-todo-log-states nil)
15034 (nshiftmax 10) (nshift 0)
15035 re type n what ts mb0 time)
14518 (when repeat 15036 (when repeat
15037 (if (eq org-log-repeat t) (setq org-log-repeat 'state))
14519 (org-todo (if (eq interpret 'type) last-state head)) 15038 (org-todo (if (eq interpret 'type) last-state head))
14520 (when (and org-log-repeat 15039 (when (and org-log-repeat
14521 (not (memq 'org-add-log-note 15040 (or (not (memq 'org-add-log-note
14522 (default-value 'post-command-hook)))) 15041 (default-value 'post-command-hook)))
14523 ;; Make sure a note is taken 15042 (eq org-log-note-purpose 'done)))
14524 (let ((org-log-done '(done))) 15043 ;; Make sure a note is taken;
14525 (org-add-log-maybe 'done (or done-word (car org-done-keywords)) 15044 (org-add-log-maybe 'state (or done-word (car org-done-keywords))
14526 'findpos))) 15045 'findpos org-log-repeat))
14527 (org-back-to-heading t) 15046 (org-back-to-heading t)
14528 (org-add-planning-info nil nil 'closed) 15047 (org-add-planning-info nil nil 'closed)
14529 (setq re (concat "\\(" org-scheduled-time-regexp "\\)\\|\\(" 15048 (setq re (concat "\\(" org-scheduled-time-regexp "\\)\\|\\("
14530 org-deadline-time-regexp "\\)")) 15049 org-deadline-time-regexp "\\)\\|\\("
15050 org-ts-regexp "\\)"))
14531 (while (re-search-forward 15051 (while (re-search-forward
14532 re (save-excursion (outline-next-heading) (point)) t) 15052 re (save-excursion (outline-next-heading) (point)) t)
14533 (setq type (if (match-end 1) org-scheduled-string org-deadline-string) 15053 (setq type (if (match-end 1) org-scheduled-string
14534 ts (match-string (if (match-end 2) 2 4))) 15054 (if (match-end 3) org-deadline-string "Plain:"))
14535 (when (string-match "\\([-+]?[0-9]+\\)\\([dwmy]\\)" ts) 15055 ts (match-string (if (match-end 2) 2 (if (match-end 4) 4 0)))
14536 (setq n (string-to-number (match-string 1 ts)) 15056 mb0 (match-beginning 0))
14537 what (match-string 2 ts)) 15057 (when (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts)
15058 (setq n (string-to-number (match-string 2 ts))
15059 what (match-string 3 ts))
14538 (if (equal what "w") (setq n (* n 7) what "d")) 15060 (if (equal what "w") (setq n (* n 7) what "d"))
14539 (org-timestamp-change n (cdr (assoc what whata)))) 15061 ;; Preparation, see if we need to modify the start date for the change
14540 (setq msg (concat msg type org-last-changed-timestamp " "))) 15062 (when (match-end 1)
15063 (setq time (save-match-data (org-time-string-to-time ts)))
15064 (cond
15065 ((equal (match-string 1 ts) ".")
15066 ;; Shift starting date to today
15067 (org-timestamp-change
15068 (- (time-to-days (current-time)) (time-to-days time))
15069 'day))
15070 ((equal (match-string 1 ts) "+")
15071 (while (< (time-to-days time) (time-to-days (current-time)))
15072 (when (= (incf nshift) nshiftmax)
15073 (or (y-or-n-p (message "%d repeater intervals were not enough to shift date past today. Continue? " nshift))
15074 (error "Abort")))
15075 (org-timestamp-change n (cdr (assoc what whata)))
15076 (sit-for .0001) ;; so we can watch the date shifting
15077 (org-at-timestamp-p t)
15078 (setq ts (match-string 1))
15079 (setq time (save-match-data (org-time-string-to-time ts))))
15080 (org-timestamp-change (- n) (cdr (assoc what whata)))
15081 ;; rematch, so that we have everything in place for the real shift
15082 (org-at-timestamp-p t)
15083 (setq ts (match-string 1))
15084 (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts))))
15085 (org-timestamp-change n (cdr (assoc what whata)))
15086 (setq msg (concat msg type org-last-changed-timestamp " "))))
14541 (setq org-log-post-message msg) 15087 (setq org-log-post-message msg)
14542 (message "%s" msg)))) 15088 (message "%s" msg))))
14543 15089
@@ -14545,7 +15091,7 @@ This function should be run in the `org-after-todo-state-change-hook'."
14545 "Make a compact tree which shows all headlines marked with TODO. 15091 "Make a compact tree which shows all headlines marked with TODO.
14546The tree will show the lines where the regexp matches, and all higher 15092The tree will show the lines where the regexp matches, and all higher
14547headlines above the match. 15093headlines above the match.
14548With \\[universal-argument] prefix, also show the DONE entries. 15094With a \\[universal-argument] prefix, also show the DONE entries.
14549With a numeric prefix N, construct a sparse tree for the Nth element 15095With a numeric prefix N, construct a sparse tree for the Nth element
14550of `org-todo-keywords-1'." 15096of `org-todo-keywords-1'."
14551 (interactive "P") 15097 (interactive "P")
@@ -14571,7 +15117,7 @@ With argument REMOVE, remove any deadline from the item."
14571 (interactive "P") 15117 (interactive "P")
14572 (if remove 15118 (if remove
14573 (progn 15119 (progn
14574 (org-add-planning-info nil nil 'deadline) 15120 (org-remove-timestamp-with-keyword org-deadline-string)
14575 (message "Item no longer has a deadline.")) 15121 (message "Item no longer has a deadline."))
14576 (org-add-planning-info 'deadline nil 'closed))) 15122 (org-add-planning-info 'deadline nil 'closed)))
14577 15123
@@ -14581,10 +15127,23 @@ With argument REMOVE, remove any scheduling date from the item."
14581 (interactive "P") 15127 (interactive "P")
14582 (if remove 15128 (if remove
14583 (progn 15129 (progn
14584 (org-add-planning-info nil nil 'scheduled) 15130 (org-remove-timestamp-with-keyword org-scheduled-string)
14585 (message "Item is no longer scheduled.")) 15131 (message "Item is no longer scheduled."))
14586 (org-add-planning-info 'scheduled nil 'closed))) 15132 (org-add-planning-info 'scheduled nil 'closed)))
14587 15133
15134(defun org-remove-timestamp-with-keyword (keyword)
15135 "Remove all time stamps with KEYWORD in the current entry."
15136 (let ((re (concat "\\<" (regexp-quote keyword) " +<[^>\n]+>[ \t]*"))
15137 beg)
15138 (save-excursion
15139 (org-back-to-heading t)
15140 (setq beg (point))
15141 (org-end-of-subtree t t)
15142 (while (re-search-backward re beg t)
15143 (replace-match "")
15144 (unless (string-match "\\S-" (buffer-substring (point-at-bol) (point)))
15145 (delete-region (point-at-bol) (min (1+ (point)) (point-max))))))))
15146
14588(defun org-add-planning-info (what &optional time &rest remove) 15147(defun org-add-planning-info (what &optional time &rest remove)
14589 "Insert new timestamp with keyword in the line directly after the headline. 15148 "Insert new timestamp with keyword in the line directly after the headline.
14590WHAT indicates what kind of time stamp to add. TIME indicated the time to use. 15149WHAT indicates what kind of time stamp to add. TIME indicated the time to use.
@@ -14657,31 +15216,34 @@ be removed."
14657(defvar org-log-note-marker (make-marker)) 15216(defvar org-log-note-marker (make-marker))
14658(defvar org-log-note-purpose nil) 15217(defvar org-log-note-purpose nil)
14659(defvar org-log-note-state nil) 15218(defvar org-log-note-state nil)
15219(defvar org-log-note-how nil)
14660(defvar org-log-note-window-configuration nil) 15220(defvar org-log-note-window-configuration nil)
14661(defvar org-log-note-return-to (make-marker)) 15221(defvar org-log-note-return-to (make-marker))
14662(defvar org-log-post-message nil 15222(defvar org-log-post-message nil
14663 "Message to be displayed after a log note has been stored. 15223 "Message to be displayed after a log note has been stored.
14664The auto-repeater uses this.") 15224The auto-repeater uses this.")
14665 15225
14666(defun org-add-log-maybe (&optional purpose state findpos) 15226(defun org-add-log-maybe (&optional purpose state findpos how)
14667 "Set up the post command hook to take a note." 15227 "Set up the post command hook to take a note.
15228If this is about to TODO state change, the new state is expected in STATE.
15229When FINDPOS is non-nil, find the correct position for the note in
15230the current entry. If not, assume that it can be inserted at point."
14668 (save-excursion 15231 (save-excursion
14669 (when (and (listp org-log-done) 15232 (when findpos
14670 (memq purpose org-log-done)) 15233 (org-back-to-heading t)
14671 (when findpos 15234 (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"
14672 (org-back-to-heading t) 15235 "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
14673 (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*" 15236 "[^\r\n]*\\)?"))
14674 "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp 15237 (goto-char (match-end 0))
14675 "[^\r\n]*\\)?")) 15238 (unless org-log-states-order-reversed
14676 (goto-char (match-end 0)) 15239 (and (= (char-after) ?\n) (forward-char 1))
14677 (unless org-log-states-order-reversed 15240 (org-skip-over-state-notes)
14678 (and (= (char-after) ?\n) (forward-char 1)) 15241 (skip-chars-backward " \t\n\r")))
14679 (org-skip-over-state-notes) 15242 (move-marker org-log-note-marker (point))
14680 (skip-chars-backward " \t\n\r"))) 15243 (setq org-log-note-purpose purpose
14681 (move-marker org-log-note-marker (point)) 15244 org-log-note-state state
14682 (setq org-log-note-purpose purpose) 15245 org-log-note-how how)
14683 (setq org-log-note-state state) 15246 (add-hook 'post-command-hook 'org-add-log-note 'append)))
14684 (add-hook 'post-command-hook 'org-add-log-note 'append))))
14685 15247
14686(defun org-skip-over-state-notes () 15248(defun org-skip-over-state-notes ()
14687 "Skip past the list of State notes in an entry." 15249 "Skip past the list of State notes in an entry."
@@ -14701,16 +15263,18 @@ The auto-repeater uses this.")
14701 (goto-char org-log-note-marker) 15263 (goto-char org-log-note-marker)
14702 (org-switch-to-buffer-other-window "*Org Note*") 15264 (org-switch-to-buffer-other-window "*Org Note*")
14703 (erase-buffer) 15265 (erase-buffer)
14704 (let ((org-inhibit-startup t)) (org-mode)) 15266 (if (memq org-log-note-how '(time state)) ; FIXME: time or state????????????
14705 (insert (format "# Insert note for %s. 15267 (org-store-log-note)
15268 (let ((org-inhibit-startup t)) (org-mode))
15269 (insert (format "# Insert note for %s.
14706# Finish with C-c C-c, or cancel with C-c C-k.\n\n" 15270# Finish with C-c C-c, or cancel with C-c C-k.\n\n"
14707 (cond 15271 (cond
14708 ((eq org-log-note-purpose 'clock-out) "stopped clock") 15272 ((eq org-log-note-purpose 'clock-out) "stopped clock")
14709 ((eq org-log-note-purpose 'done) "closed todo item") 15273 ((eq org-log-note-purpose 'done) "closed todo item")
14710 ((eq org-log-note-purpose 'state) 15274 ((eq org-log-note-purpose 'state)
14711 (format "state change to \"%s\"" org-log-note-state)) 15275 (format "state change to \"%s\"" org-log-note-state))
14712 (t (error "This should not happen"))))) 15276 (t (error "This should not happen")))))
14713 (org-set-local 'org-finish-function 'org-store-log-note)) 15277 (org-set-local 'org-finish-function 'org-store-log-note)))
14714 15278
14715(defun org-store-log-note () 15279(defun org-store-log-note ()
14716 "Finish taking a log note, and insert it to where it belongs." 15280 "Finish taking a log note, and insert it to where it belongs."
@@ -14800,8 +15364,20 @@ d Show deadlines due within `org-deadline-warning-days'."
14800 (call-interactively 'org-occur)) 15364 (call-interactively 'org-occur))
14801 (t (error "No such sparse tree command \"%c\"" ans))))) 15365 (t (error "No such sparse tree command \"%c\"" ans)))))
14802 15366
14803(defvar org-occur-highlights nil) 15367(defvar org-occur-highlights nil
15368 "List of overlays used for occur matches.")
14804(make-variable-buffer-local 'org-occur-highlights) 15369(make-variable-buffer-local 'org-occur-highlights)
15370(defvar org-occur-parameters nil
15371 "Parameters of the active org-occur calls.
15372This is a list, each call to org-occur pushes as cons cell,
15373containing the regular expression and the callback, onto the list.
15374The list can contain several entries if `org-occur' has been called
15375several time with the KEEP-PREVIOUS argument. Otherwise, this list
15376will only contain one set of parameters. When the highlights are
15377removed (for example with `C-c C-c', or with the next edit (depending
15378on `org-remove-highlights-with-change'), this variable is emptied
15379as well.")
15380(make-variable-buffer-local 'org-occur-parameters)
14805 15381
14806(defun org-occur (regexp &optional keep-previous callback) 15382(defun org-occur (regexp &optional keep-previous callback)
14807 "Make a compact tree which shows all matches of REGEXP. 15383 "Make a compact tree which shows all matches of REGEXP.
@@ -14814,7 +15390,9 @@ command.
14814If CALLBACK is non-nil, it is a function which is called to confirm 15390If CALLBACK is non-nil, it is a function which is called to confirm
14815that the match should indeed be shown." 15391that the match should indeed be shown."
14816 (interactive "sRegexp: \nP") 15392 (interactive "sRegexp: \nP")
14817 (or keep-previous (org-remove-occur-highlights nil nil t)) 15393 (unless keep-previous
15394 (org-remove-occur-highlights nil nil t))
15395 (push (cons regexp callback) org-occur-parameters)
14818 (let ((cnt 0)) 15396 (let ((cnt 0))
14819 (save-excursion 15397 (save-excursion
14820 (goto-char (point-min)) 15398 (goto-char (point-min))
@@ -14900,6 +15478,7 @@ from the `before-change-functions' in the current buffer."
14900 (unless org-inhibit-highlight-removal 15478 (unless org-inhibit-highlight-removal
14901 (mapc 'org-delete-overlay org-occur-highlights) 15479 (mapc 'org-delete-overlay org-occur-highlights)
14902 (setq org-occur-highlights nil) 15480 (setq org-occur-highlights nil)
15481 (setq org-occur-parameters nil)
14903 (unless noremove 15482 (unless noremove
14904 (remove-hook 'before-change-functions 15483 (remove-hook 'before-change-functions
14905 'org-remove-occur-highlights 'local)))) 15484 'org-remove-occur-highlights 'local))))
@@ -15106,14 +15685,18 @@ also TODO lines."
15106 "Return the list of all tags in all agenda buffer/files." 15685 "Return the list of all tags in all agenda buffer/files."
15107 (save-excursion 15686 (save-excursion
15108 (org-uniquify 15687 (org-uniquify
15109 (apply 'append 15688 (delq nil
15110 (mapcar 15689 (apply 'append
15111 (lambda (file) 15690 (mapcar
15112 (set-buffer (find-file-noselect file)) 15691 (lambda (file)
15113 (org-get-buffer-tags)) 15692 (set-buffer (find-file-noselect file))
15114 (if (and files (car files)) 15693 (append (org-get-buffer-tags)
15115 files 15694 (mapcar (lambda (x) (if (stringp (car-safe x))
15116 (org-agenda-files))))))) 15695 (list (car-safe x)) nil))
15696 org-tag-alist)))
15697 (if (and files (car files))
15698 files
15699 (org-agenda-files))))))))
15117 15700
15118(defun org-make-tags-matcher (match) 15701(defun org-make-tags-matcher (match)
15119 "Create the TAGS//TODO matcher form for the selection string MATCH." 15702 "Create the TAGS//TODO matcher form for the selection string MATCH."
@@ -15129,7 +15712,7 @@ also TODO lines."
15129 15712
15130 ;; Parse the string and create a lisp form 15713 ;; Parse the string and create a lisp form
15131 (let ((match0 match) 15714 (let ((match0 match)
15132 (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL=\\([0-9]+\\)\\|\\([[:alnum:]_]+\\)=\\({[^}]+}\\|\"[^\"]+\"\\)\\|[[:alnum:]_@]+\\)")) 15715 (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL=\\([0-9]+\\)\\|\\([[:alnum:]_]+\\)=\\({[^}]+}\\|\"[^\"]*\"\\)\\|[[:alnum:]_@]+\\)"))
15133 minus tag mm 15716 minus tag mm
15134 tagsmatch todomatch tagsmatcher todomatcher kwd matcher 15717 tagsmatch todomatch tagsmatcher todomatcher kwd matcher
15135 orterms term orlist re-p level-p prop-p pn pv cat-p gv) 15718 orterms term orlist re-p level-p prop-p pn pv cat-p gv)
@@ -15174,7 +15757,7 @@ also TODO lines."
15174 (setq gv `(org-cached-entry-get nil ,pn))) 15757 (setq gv `(org-cached-entry-get nil ,pn)))
15175 (if re-p 15758 (if re-p
15176 `(string-match ,pv (or ,gv "")) 15759 `(string-match ,pv (or ,gv ""))
15177 `(equal ,pv ,gv))) 15760 `(equal ,pv (or ,gv ""))))
15178 (t `(member ,(downcase tag) tags-list))) 15761 (t `(member ,(downcase tag) tags-list)))
15179 mm (if minus (list 'not mm) mm) 15762 mm (if minus (list 'not mm) mm)
15180 term (substring term (match-end 0))) 15763 term (substring term (match-end 0)))
@@ -15315,7 +15898,7 @@ With prefix ARG, realign all tags in headings in the current buffer."
15315 (- (- org-tags-column) (length tags)))) 15898 (- (- org-tags-column) (length tags))))
15316 rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags))) 15899 rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags)))
15317 (replace-match rpl t t) 15900 (replace-match rpl t t)
15318 (and (not (featurep 'xemacs)) c0 (tabify p0 (point))) 15901 (and (not (featurep 'xemacs)) c0 indent-tabs-mode (tabify p0 (point)))
15319 tags) 15902 tags)
15320 (t (error "Tags alignment failed"))) 15903 (t (error "Tags alignment failed")))
15321 (move-to-column col) 15904 (move-to-column col)
@@ -15921,13 +16504,15 @@ If the property is not present at all, nil is returned."
15921 (and value (insert " " value)) 16504 (and value (insert " " value))
15922 (org-indent-line-function))))))) 16505 (org-indent-line-function)))))))
15923 16506
15924(defun org-buffer-property-keys (&optional include-specials include-defaults) 16507(defun org-buffer-property-keys (&optional include-specials include-defaults include-columns)
15925 "Get all property keys in the current buffer. 16508 "Get all property keys in the current buffer.
15926With INCLUDE-SPECIALS, also list the special properties that relect things 16509With INCLUDE-SPECIALS, also list the special properties that relect things
15927like tags and TODO state. 16510like tags and TODO state.
15928With INCLUDE-DEFAULTS, also include properties that has special meaning 16511With INCLUDE-DEFAULTS, also include properties that has special meaning
15929internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING." 16512internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING.
15930 (let (rtn range) 16513With INCLUDE-COLUMNS, also include property names given in COLUMN
16514formats in the current buffer."
16515 (let (rtn range cfmt cols s p)
15931 (save-excursion 16516 (save-excursion
15932 (save-restriction 16517 (save-restriction
15933 (widen) 16518 (widen)
@@ -15936,7 +16521,7 @@ internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING."
15936 (setq range (org-get-property-block)) 16521 (setq range (org-get-property-block))
15937 (goto-char (car range)) 16522 (goto-char (car range))
15938 (while (re-search-forward 16523 (while (re-search-forward
15939 (org-re "^[ \t]*:\\([[:alnum:]_-]+\\):") 16524 (org-re "^[ \t]*:\\([-[:alnum:]_]+\\):")
15940 (cdr range) t) 16525 (cdr range) t)
15941 (add-to-list 'rtn (org-match-string-no-properties 1))) 16526 (add-to-list 'rtn (org-match-string-no-properties 1)))
15942 (outline-next-heading)))) 16527 (outline-next-heading))))
@@ -15947,6 +16532,23 @@ internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING."
15947 (when include-defaults 16532 (when include-defaults
15948 (mapc (lambda (x) (add-to-list 'rtn x)) org-default-properties)) 16533 (mapc (lambda (x) (add-to-list 'rtn x)) org-default-properties))
15949 16534
16535 (when include-columns
16536 (save-excursion
16537 (save-restriction
16538 (widen)
16539 (goto-char (point-min))
16540 (while (re-search-forward
16541 "^\\(#\\+COLUMNS:\\|[ \t]*:COLUMNS:\\)[ \t]*\\(.*\\)"
16542 nil t)
16543 (setq cfmt (match-string 2) s 0)
16544 (while (string-match (org-re "%[0-9]*\\([-[:alnum:]_]+\\)")
16545 cfmt s)
16546 (setq s (match-end 0)
16547 p (match-string 1 cfmt))
16548 (unless (or (equal p "ITEM")
16549 (member p org-special-properties))
16550 (add-to-list 'rtn (match-string 1 cfmt))))))))
16551
15950 (sort rtn (lambda (a b) (string< (upcase a) (upcase b)))))) 16552 (sort rtn (lambda (a b) (string< (upcase a) (upcase b))))))
15951 16553
15952(defun org-property-values (key) 16554(defun org-property-values (key)
@@ -16001,7 +16603,7 @@ xxx_ALL property) or on existing values in other instances of this property
16001in the current file." 16603in the current file."
16002 (interactive 16604 (interactive
16003 (let* ((prop (completing-read 16605 (let* ((prop (completing-read
16004 "Property: " (mapcar 'list (org-buffer-property-keys nil t)))) 16606 "Property: " (mapcar 'list (org-buffer-property-keys nil t t))))
16005 (cur (org-entry-get nil prop)) 16607 (cur (org-entry-get nil prop))
16006 (allowed (org-property-get-allowed-values nil prop 'table)) 16608 (allowed (org-property-get-allowed-values nil prop 'table))
16007 (existing (mapcar 'list (org-property-values prop))) 16609 (existing (mapcar 'list (org-property-values prop)))
@@ -16132,6 +16734,7 @@ Return the position where this entry starts, or nil if there is no such entry."
16132 (case-fold-search nil)) 16734 (case-fold-search nil))
16133 (save-excursion 16735 (save-excursion
16134 (save-restriction 16736 (save-restriction
16737 (widen)
16135 (goto-char (point-min)) 16738 (goto-char (point-min))
16136 (when (re-search-forward 16739 (when (re-search-forward
16137 (concat "^[ \t]*:ID:[ \t]+" (regexp-quote id) "[ \t]*$") 16740 (concat "^[ \t]*:ID:[ \t]+" (regexp-quote id) "[ \t]*$")
@@ -16176,6 +16779,7 @@ This is the compiled version of the format.")
16176(org-defkey org-columns-map "v" 'org-columns-show-value) 16779(org-defkey org-columns-map "v" 'org-columns-show-value)
16177(org-defkey org-columns-map "q" 'org-columns-quit) 16780(org-defkey org-columns-map "q" 'org-columns-quit)
16178(org-defkey org-columns-map "r" 'org-columns-redo) 16781(org-defkey org-columns-map "r" 'org-columns-redo)
16782(org-defkey org-columns-map "g" 'org-columns-redo)
16179(org-defkey org-columns-map [left] 'backward-char) 16783(org-defkey org-columns-map [left] 'backward-char)
16180(org-defkey org-columns-map "\M-b" 'backward-char) 16784(org-defkey org-columns-map "\M-b" 'backward-char)
16181(org-defkey org-columns-map "a" 'org-columns-edit-allowed) 16785(org-defkey org-columns-map "a" 'org-columns-edit-allowed)
@@ -16459,7 +17063,8 @@ Where possible, use the standard interface for changing this line."
16459 (org-columns-eval eval)) 17063 (org-columns-eval eval))
16460 (org-columns-display-here)))) 17064 (org-columns-display-here))))
16461 (move-to-column col) 17065 (move-to-column col)
16462 (if (nth 3 (assoc key org-columns-current-fmt-compiled)) 17066 (if (and (org-mode-p)
17067 (nth 3 (assoc key org-columns-current-fmt-compiled)))
16463 (org-columns-update key)))) 17068 (org-columns-update key))))
16464 17069
16465(defun org-edit-headline () ; FIXME: this is not columns specific 17070(defun org-edit-headline () ; FIXME: this is not columns specific
@@ -16532,9 +17137,10 @@ Where possible, use the standard interface for changing this line."
16532 x)) 17137 x))
16533 org-columns-overlays))) 17138 org-columns-overlays)))
16534 (allowed (or (org-property-get-allowed-values pom key) 17139 (allowed (or (org-property-get-allowed-values pom key)
16535 (and (equal 17140 (and (memq
16536 (nth 4 (assoc key org-columns-current-fmt-compiled)) 17141 (nth 4 (assoc key org-columns-current-fmt-compiled))
16537 'checkbox) '("[ ]" "[X]")))) 17142 '(checkbox checkbox-n-of-m checkbox-percent))
17143 '("[ ]" "[X]"))))
16538 nval) 17144 nval)
16539 (when (equal key "ITEM") 17145 (when (equal key "ITEM")
16540 (error "Cannot edit item headline from here")) 17146 (error "Cannot edit item headline from here"))
@@ -16558,7 +17164,8 @@ Where possible, use the standard interface for changing this line."
16558 (org-columns-eval '(org-entry-put pom key nval))) 17164 (org-columns-eval '(org-entry-put pom key nval)))
16559 (org-columns-display-here))) 17165 (org-columns-display-here)))
16560 (move-to-column col) 17166 (move-to-column col)
16561 (if (nth 3 (assoc key org-columns-current-fmt-compiled)) 17167 (if (and (org-mode-p)
17168 (nth 3 (assoc key org-columns-current-fmt-compiled)))
16562 (org-columns-update key)))) 17169 (org-columns-update key))))
16563 17170
16564(defun org-verify-version (task) 17171(defun org-verify-version (task)
@@ -16570,9 +17177,8 @@ Where possible, use the standard interface for changing this line."
16570 17177
16571(defun org-columns-open-link (&optional arg) 17178(defun org-columns-open-link (&optional arg)
16572 (interactive "P") 17179 (interactive "P")
16573 (let ((key (get-char-property (point) 'org-columns-key)) 17180 (let ((value (get-char-property (point) 'org-columns-value)))
16574 (value (get-char-property (point) 'org-columns-value))) 17181 (org-open-link-from-string value arg)))
16575 (org-open-link-from-string arg)))
16576 17182
16577(defun org-open-link-from-string (s &optional arg) 17183(defun org-open-link-from-string (s &optional arg)
16578 "Open a link in the string S, as if it was in Org-mode." 17184 "Open a link in the string S, as if it was in Org-mode."
@@ -16604,7 +17210,7 @@ Where possible, use the standard interface for changing this line."
16604 (org-verify-version 'columns) 17210 (org-verify-version 'columns)
16605 (org-columns-remove-overlays) 17211 (org-columns-remove-overlays)
16606 (move-marker org-columns-begin-marker (point)) 17212 (move-marker org-columns-begin-marker (point))
16607 (let (beg end fmt cache maxwidths clocksump) 17213 (let (beg end fmt cache maxwidths)
16608 (setq fmt (org-columns-get-format-and-top-level)) 17214 (setq fmt (org-columns-get-format-and-top-level))
16609 (save-excursion 17215 (save-excursion
16610 (goto-char org-columns-top-level-marker) 17216 (goto-char org-columns-top-level-marker)
@@ -16616,7 +17222,6 @@ Where possible, use the standard interface for changing this line."
16616 ;; Get and cache the properties 17222 ;; Get and cache the properties
16617 (goto-char beg) 17223 (goto-char beg)
16618 (when (assoc "CLOCKSUM" org-columns-current-fmt-compiled) 17224 (when (assoc "CLOCKSUM" org-columns-current-fmt-compiled)
16619 (setq clocksump t)
16620 (save-excursion 17225 (save-excursion
16621 (save-restriction 17226 (save-restriction
16622 (narrow-to-region beg end) 17227 (narrow-to-region beg end)
@@ -16638,7 +17243,7 @@ Where possible, use the standard interface for changing this line."
16638 (let ((editp (and prop (assoc prop org-columns-current-fmt-compiled))) 17243 (let ((editp (and prop (assoc prop org-columns-current-fmt-compiled)))
16639 cell) 17244 cell)
16640 (setq prop (completing-read 17245 (setq prop (completing-read
16641 "Property: " (mapcar 'list (org-buffer-property-keys t)) 17246 "Property: " (mapcar 'list (org-buffer-property-keys t nil t))
16642 nil nil prop)) 17247 nil nil prop))
16643 (setq title (read-string (concat "Column title [" prop "]: ") (or title prop))) 17248 (setq title (read-string (concat "Column title [" prop "]: ") (or title prop)))
16644 (setq width (read-string "Column width: " (if width (number-to-string width)))) 17249 (setq width (read-string "Column width: " (if width (number-to-string width))))
@@ -16646,7 +17251,7 @@ Where possible, use the standard interface for changing this line."
16646 (setq width (string-to-number width)) 17251 (setq width (string-to-number width))
16647 (setq width nil)) 17252 (setq width nil))
16648 (setq fmt (completing-read "Summary [none]: " 17253 (setq fmt (completing-read "Summary [none]: "
16649 '(("none") ("add_numbers") ("currency") ("add_times") ("checkbox")) 17254 '(("none") ("add_numbers") ("currency") ("add_times") ("checkbox") ("checkbox-n-of-m") ("checkbox-percent"))
16650 nil t)) 17255 nil t))
16651 (if (string-match "\\S-" fmt) 17256 (if (string-match "\\S-" fmt)
16652 (setq fmt (intern fmt)) 17257 (setq fmt (intern fmt))
@@ -16800,7 +17405,7 @@ display, or in the #+COLUMNS line of the current buffer."
16800(defun org-columns-get-autowidth-alist (s cache) 17405(defun org-columns-get-autowidth-alist (s cache)
16801 "Derive the maximum column widths from the format and the cache." 17406 "Derive the maximum column widths from the format and the cache."
16802 (let ((start 0) rtn) 17407 (let ((start 0) rtn)
16803 (while (string-match (org-re "%\\([[:alpha:]]\\S-*\\)") s start) 17408 (while (string-match (org-re "%\\([[:alpha:]][[:alnum:]_-]*\\)") s start)
16804 (push (cons (match-string 1 s) 1) rtn) 17409 (push (cons (match-string 1 s) 1) rtn)
16805 (setq start (match-end 0))) 17410 (setq start (match-end 0)))
16806 (mapc (lambda (x) 17411 (mapc (lambda (x)
@@ -16935,11 +17540,19 @@ display, or in the #+COLUMNS line of the current buffer."
16935 (cond ((= n (floor n)) "[X]") 17540 (cond ((= n (floor n)) "[X]")
16936 ((> n 1.) "[-]") 17541 ((> n 1.) "[-]")
16937 (t "[ ]"))) 17542 (t "[ ]")))
17543 ((memq fmt '(checkbox-n-of-m checkbox-percent))
17544 (let* ((n1 (floor n)) (n2 (floor (+ .5 (* 1000000 (- n n1))))))
17545 (org-nofm-to-completion n1 (+ n2 n1) (eq fmt 'checkbox-percent))))
16938 (printf (format printf n)) 17546 (printf (format printf n))
16939 ((eq fmt 'currency) 17547 ((eq fmt 'currency)
16940 (format "%.2f" n)) 17548 (format "%.2f" n))
16941 (t (number-to-string n)))) 17549 (t (number-to-string n))))
16942 17550
17551(defun org-nofm-to-completion (n m &optional percent)
17552 (if (not percent)
17553 (format "[%d/%d]" n m)
17554 (format "[%d%%]"(floor (+ 0.5 (* 100. (/ (* 1.0 n) m)))))))
17555
16943(defun org-column-string-to-number (s fmt) 17556(defun org-column-string-to-number (s fmt)
16944 "Convert a column value to a number that can be used for column computing." 17557 "Convert a column value to a number that can be used for column computing."
16945 (cond 17558 (cond
@@ -16948,7 +17561,7 @@ display, or in the #+COLUMNS line of the current buffer."
16948 (while l 17561 (while l
16949 (setq sum (+ (string-to-number (pop l)) (/ sum 60)))) 17562 (setq sum (+ (string-to-number (pop l)) (/ sum 60))))
16950 sum)) 17563 sum))
16951 ((eq fmt 'checkbox) 17564 ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent))
16952 (if (equal s "[X]") 1. 0.000001)) 17565 (if (equal s "[X]") 1. 0.000001))
16953 (t (string-to-number s)))) 17566 (t (string-to-number s))))
16954 17567
@@ -16965,6 +17578,8 @@ display, or in the #+COLUMNS line of the current buffer."
16965 (cond 17578 (cond
16966 ((eq fmt 'add_times) (setq op ":")) 17579 ((eq fmt 'add_times) (setq op ":"))
16967 ((eq fmt 'checkbox) (setq op "X")) 17580 ((eq fmt 'checkbox) (setq op "X"))
17581 ((eq fmt 'checkbox-n-of-m) (setq op "X/"))
17582 ((eq fmt 'checkbox-percent) (setq op "X%"))
16968 ((eq fmt 'add_numbers) (setq op "+")) 17583 ((eq fmt 'add_numbers) (setq op "+"))
16969 ((eq fmt 'currency) (setq op "$"))) 17584 ((eq fmt 'currency) (setq op "$")))
16970 (if (and op printf) (setq op (concat op ";" printf))) 17585 (if (and op printf) (setq op (concat op ";" printf)))
@@ -17003,10 +17618,13 @@ printf a printf format for computed values"
17003 (setq printf (substring op (match-end 0)) 17618 (setq printf (substring op (match-end 0))
17004 op (substring op 0 (match-beginning 0)))) 17619 op (substring op 0 (match-beginning 0))))
17005 (cond 17620 (cond
17006 ((equal op "+") (setq f 'add_numbers)) 17621 ((equal op "+") (setq f 'add_numbers))
17007 ((equal op "$") (setq f 'currency)) 17622 ((equal op "$") (setq f 'currency))
17008 ((equal op ":") (setq f 'add_times)) 17623 ((equal op ":") (setq f 'add_times))
17009 ((equal op "X") (setq f 'checkbox))) 17624 ((equal op "X") (setq f 'checkbox))
17625 ((equal op "X/") (setq f 'checkbox-n-of-m))
17626 ((equal op "X%") (setq f 'checkbox-percent))
17627 )
17010 (push (list prop title width op f printf) org-columns-current-fmt-compiled)) 17628 (push (list prop title width op f printf) org-columns-current-fmt-compiled))
17011 (setq org-columns-current-fmt-compiled 17629 (setq org-columns-current-fmt-compiled
17012 (nreverse org-columns-current-fmt-compiled)))) 17630 (nreverse org-columns-current-fmt-compiled))))
@@ -17014,15 +17632,24 @@ printf a printf format for computed values"
17014 17632
17015;;; Dynamic block for Column view 17633;;; Dynamic block for Column view
17016 17634
17017(defun org-columns-capture-view () 17635(defun org-columns-capture-view (&optional maxlevel skip-empty-rows)
17018 "Get the column view of the current buffer and return it as a list. 17636 "Get the column view of the current buffer or subtree.
17019The list will contains the title row and all other rows. Each row is 17637The first optional argument MAXLEVEL sets the level limit. A
17020a list of fields." 17638second optional argument SKIP-EMPTY-ROWS tells whether to skip
17639empty rows, an empty row being one where all the column view
17640specifiers except ITEM are empty. This function returns a list
17641containing the title row and all other rows. Each row is a list
17642of fields."
17021 (save-excursion 17643 (save-excursion
17022 (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) 17644 (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled))
17023 (n (length title)) row tbl) 17645 (n (length title)) row tbl)
17024 (goto-char (point-min)) 17646 (goto-char (point-min))
17025 (while (re-search-forward "^\\*+ " nil t) 17647 (while (and (re-search-forward "^\\(\\*+\\) " nil t)
17648 (or (null maxlevel)
17649 (>= maxlevel
17650 (if org-odd-levels-only
17651 (/ (1+ (length (match-string 1))) 2)
17652 (length (match-string 1))))))
17026 (when (get-char-property (match-beginning 0) 'org-columns-key) 17653 (when (get-char-property (match-beginning 0) 'org-columns-key)
17027 (setq row nil) 17654 (setq row nil)
17028 (loop for i from 0 to (1- n) do 17655 (loop for i from 0 to (1- n) do
@@ -17031,7 +17658,9 @@ a list of fields."
17031 "") 17658 "")
17032 row)) 17659 row))
17033 (setq row (nreverse row)) 17660 (setq row (nreverse row))
17034 (push row tbl))) 17661 (unless (and skip-empty-rows
17662 (eq 1 (length (delete "" (delete-dups row)))))
17663 (push row tbl))))
17035 (append (list title 'hline) (nreverse tbl))))) 17664 (append (list title 'hline) (nreverse tbl)))))
17036 17665
17037(defun org-dblock-write:columnview (params) 17666(defun org-dblock-write:columnview (params)
@@ -17046,10 +17675,15 @@ PARAMS is a property list of parameters:
17046 to column view). 17675 to column view).
17047:hlines When t, insert a hline before each item. When a number, insert 17676:hlines When t, insert a hline before each item. When a number, insert
17048 a hline before each level <= that number. 17677 a hline before each level <= that number.
17049:vlines When t, make each column a colgroup to enforce vertical lines." 17678:vlines When t, make each column a colgroup to enforce vertical lines.
17679:maxlevel When set to a number, don't capture headlines below this level.
17680:skip-empty-rows
17681 When t, skip rows where all specifiers other than ITEM are empty."
17050 (let ((pos (move-marker (make-marker) (point))) 17682 (let ((pos (move-marker (make-marker) (point)))
17051 (hlines (plist-get params :hlines)) 17683 (hlines (plist-get params :hlines))
17052 (vlines (plist-get params :vlines)) 17684 (vlines (plist-get params :vlines))
17685 (maxlevel (plist-get params :maxlevel))
17686 (skip-empty-rows (plist-get params :skip-empty-rows))
17053 tbl id idpos nfields tmp) 17687 tbl id idpos nfields tmp)
17054 (save-excursion 17688 (save-excursion
17055 (save-restriction 17689 (save-restriction
@@ -17061,7 +17695,7 @@ PARAMS is a property list of parameters:
17061 (goto-char idpos)) 17695 (goto-char idpos))
17062 (t (error "Cannot find entry with :ID: %s" id)))) 17696 (t (error "Cannot find entry with :ID: %s" id))))
17063 (org-columns) 17697 (org-columns)
17064 (setq tbl (org-columns-capture-view)) 17698 (setq tbl (org-columns-capture-view maxlevel skip-empty-rows))
17065 (setq nfields (length (car tbl))) 17699 (setq nfields (length (car tbl)))
17066 (org-columns-quit))) 17700 (org-columns-quit)))
17067 (goto-char pos) 17701 (goto-char pos)
@@ -17266,7 +17900,7 @@ the time/date that is used for everything that is not specified by the
17266user." 17900user."
17267 (require 'parse-time) 17901 (require 'parse-time)
17268 (let* ((org-time-stamp-rounding-minutes 17902 (let* ((org-time-stamp-rounding-minutes
17269 (if (equal with-time '(16)) 0 org-time-stamp-rounding-minutes)) 17903 (if (equal with-time '(16)) '(0 0) org-time-stamp-rounding-minutes))
17270 (org-dcst org-display-custom-times) 17904 (org-dcst org-display-custom-times)
17271 (ct (org-current-time)) 17905 (ct (org-current-time))
17272 (def (or default-time ct)) 17906 (def (or default-time ct))
@@ -17620,7 +18254,7 @@ The command returns the inserted time stamp."
17620 t1 w1 with-hm tf time str w2 (off 0)) 18254 t1 w1 with-hm tf time str w2 (off 0))
17621 (save-match-data 18255 (save-match-data
17622 (setq t1 (org-parse-time-string ts t)) 18256 (setq t1 (org-parse-time-string ts t))
17623 (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\( \\+[0-9]+[dwmy]\\)?\\'" ts) 18257 (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\( [.+]?\\+[0-9]+[dwmy]\\)?\\'" ts)
17624 (setq off (- (match-end 0) (match-beginning 0))))) 18258 (setq off (- (match-end 0) (match-beginning 0)))))
17625 (setq end (- end off)) 18259 (setq end (- end off))
17626 (setq w1 (- end beg) 18260 (setq w1 (- end beg)
@@ -17826,7 +18460,7 @@ days in order to avoid rounding problems."
17826(defun org-time-string-to-time (s) 18460(defun org-time-string-to-time (s)
17827 (apply 'encode-time (org-parse-time-string s))) 18461 (apply 'encode-time (org-parse-time-string s)))
17828 18462
17829(defun org-time-string-to-absolute (s &optional daynr) 18463(defun org-time-string-to-absolute (s &optional daynr prefer)
17830 "Convert a time stamp to an absolute day number. 18464 "Convert a time stamp to an absolute day number.
17831If there is a specifyer for a cyclic time stamp, get the closest date to 18465If there is a specifyer for a cyclic time stamp, get the closest date to
17832DAYNR." 18466DAYNR."
@@ -17837,7 +18471,8 @@ DAYNR."
17837 (+ daynr 1000))) 18471 (+ daynr 1000)))
17838 ((and daynr (string-match "\\+[0-9]+[dwmy]" s)) 18472 ((and daynr (string-match "\\+[0-9]+[dwmy]" s))
17839 (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr 18473 (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr
17840 (time-to-days (current-time))) (match-string 0 s))) 18474 (time-to-days (current-time))) (match-string 0 s)
18475 prefer))
17841 (t (time-to-days (apply 'encode-time (org-parse-time-string s)))))) 18476 (t (time-to-days (apply 'encode-time (org-parse-time-string s))))))
17842 18477
17843(defun org-time-from-absolute (d) 18478(defun org-time-from-absolute (d)
@@ -17900,8 +18535,10 @@ This uses the icalendar.el library."
17900 (delete-file tmpfile) 18535 (delete-file tmpfile)
17901 rtn)) 18536 rtn))
17902 18537
17903(defun org-closest-date (start current change) 18538(defun org-closest-date (start current change prefer)
17904 "Find the date closest to CURRENT that is consistent with START and CHANGE." 18539 "Find the date closest to CURRENT that is consistent with START and CHANGE.
18540When PREFER is `past' return a date that is either CURRENT or past.
18541When PREFER is `future', return a date that is either CURRENT or future."
17905 ;; Make the proper lists from the dates 18542 ;; Make the proper lists from the dates
17906 (catch 'exit 18543 (catch 'exit
17907 (let ((a1 '(("d" . day) ("w" . week) ("m" . month) ("y" . year))) 18544 (let ((a1 '(("d" . day) ("w" . week) ("m" . month) ("y" . year)))
@@ -17956,8 +18593,14 @@ This uses the icalendar.el library."
17956 (setq n2 (calendar-absolute-from-gregorian (list m2 d y2)))))) 18593 (setq n2 (calendar-absolute-from-gregorian (list m2 d y2))))))
17957 18594
17958 (if org-agenda-repeating-timestamp-show-all 18595 (if org-agenda-repeating-timestamp-show-all
17959 (if (> (abs (- cday n1)) (abs (- cday n2))) n2 n1) 18596 (cond
17960 (if (= cday n1) n1 n2))))) 18597 ((eq prefer 'past) n1)
18598 ((eq prefer 'future) (if (= cday n1) n1 n2))
18599 (t (if (> (abs (- cday n1)) (abs (- cday n2))) n2 n1)))
18600 (cond
18601 ((eq prefer 'past) n1)
18602 ((eq prefer 'future) (if (= cday n1) n1 n2))
18603 (t (if (= cday n1) n1 n2)))))))
17961 18604
17962(defun org-date-to-gregorian (date) 18605(defun org-date-to-gregorian (date)
17963 "Turn any specification of DATE into a gregorian date for the calendar." 18606 "Turn any specification of DATE into a gregorian date for the calendar."
@@ -18055,7 +18698,7 @@ With prefix ARG, change that many days."
18055 ans)) 18698 ans))
18056 18699
18057(defun org-toggle-timestamp-type () 18700(defun org-toggle-timestamp-type ()
18058 "" 18701 "Toggle the type (<active> or [inactive]) of a time stamp."
18059 (interactive) 18702 (interactive)
18060 (when (org-at-timestamp-p t) 18703 (when (org-at-timestamp-p t)
18061 (save-excursion 18704 (save-excursion
@@ -18073,8 +18716,9 @@ The date will be changed by N times WHAT. WHAT can be `day', `month',
18073in the timestamp determines what will be changed." 18716in the timestamp determines what will be changed."
18074 (let ((pos (point)) 18717 (let ((pos (point))
18075 with-hm inactive 18718 with-hm inactive
18719 (dm (max (nth 1 org-time-stamp-rounding-minutes) 1))
18076 org-ts-what 18720 org-ts-what
18077 extra 18721 extra rem
18078 ts time time0) 18722 ts time time0)
18079 (if (not (org-at-timestamp-p t)) 18723 (if (not (org-at-timestamp-p t))
18080 (error "Not at a timestamp")) 18724 (error "Not at a timestamp"))
@@ -18090,12 +18734,18 @@ in the timestamp determines what will be changed."
18090 ts (match-string 0)) 18734 ts (match-string 0))
18091 (replace-match "") 18735 (replace-match "")
18092 (if (string-match 18736 (if (string-match
18093 "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( [-+][0-9]+[dwmy]\\)*\\)[]>]" 18737 "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?[-+][0-9]+[dwmy]\\)*\\)[]>]"
18094 ts) 18738 ts)
18095 (setq extra (match-string 1 ts))) 18739 (setq extra (match-string 1 ts)))
18096 (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts) 18740 (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
18097 (setq with-hm t)) 18741 (setq with-hm t))
18098 (setq time0 (org-parse-time-string ts)) 18742 (setq time0 (org-parse-time-string ts))
18743 (when (and (eq org-ts-what 'minute)
18744 (eq current-prefix-arg nil))
18745 (setq n (* dm (org-no-warnings (signum n))))
18746 (when (not (= 0 (setq rem (% (nth 1 time0) dm))))
18747 (setcar (cdr time0) (+ (nth 1 time0)
18748 (if (> n 0) (- rem) (- dm rem))))))
18099 (setq time 18749 (setq time
18100 (encode-time (or (car time0) 0) 18750 (encode-time (or (car time0) 0)
18101 (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0)) 18751 (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0))
@@ -18105,7 +18755,7 @@ in the timestamp determines what will be changed."
18105 (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0)) 18755 (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0))
18106 (nthcdr 6 time0))) 18756 (nthcdr 6 time0)))
18107 (when (integerp org-ts-what) 18757 (when (integerp org-ts-what)
18108 (setq extra (org-modify-ts-extra extra org-ts-what n))) 18758 (setq extra (org-modify-ts-extra extra org-ts-what n dm)))
18109 (if (eq what 'calendar) 18759 (if (eq what 'calendar)
18110 (let ((cal-date (org-get-date-from-calendar))) 18760 (let ((cal-date (org-get-date-from-calendar)))
18111 (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month 18761 (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month
@@ -18126,11 +18776,11 @@ in the timestamp determines what will be changed."
18126 (org-recenter-calendar (time-to-days time)))))) 18776 (org-recenter-calendar (time-to-days time))))))
18127 18777
18128;; FIXME: does not yet work for lead times 18778;; FIXME: does not yet work for lead times
18129(defun org-modify-ts-extra (s pos n) 18779(defun org-modify-ts-extra (s pos n dm)
18130 "Change the different parts of the lead-time and repeat fields in timestamp." 18780 "Change the different parts of the lead-time and repeat fields in timestamp."
18131 (let ((idx '(("d" . 0) ("w" . 1) ("m" . 2) ("y" . 3) ("d" . -1) ("y" . 4))) 18781 (let ((idx '(("d" . 0) ("w" . 1) ("m" . 2) ("y" . 3) ("d" . -1) ("y" . 4)))
18132 ng h m new) 18782 ng h m new rem)
18133 (when (string-match "\\(-\\([012][0-9]\\):\\([0-5][0-9]\\)\\)?\\( \\+\\([0-9]+\\)\\([dmwy]\\)\\)?" s) 18783 (when (string-match "\\(-\\([012][0-9]\\):\\([0-5][0-9]\\)\\)?\\( +\\+\\([0-9]+\\)\\([dmwy]\\)\\)?\\( +-\\([0-9]+\\)\\([dmwy]\\)\\)?" s)
18134 (cond 18784 (cond
18135 ((or (org-pos-in-match-range pos 2) 18785 ((or (org-pos-in-match-range pos 2)
18136 (org-pos-in-match-range pos 3)) 18786 (org-pos-in-match-range pos 3))
@@ -18138,6 +18788,9 @@ in the timestamp determines what will be changed."
18138 h (string-to-number (match-string 2 s))) 18788 h (string-to-number (match-string 2 s)))
18139 (if (org-pos-in-match-range pos 2) 18789 (if (org-pos-in-match-range pos 2)
18140 (setq h (+ h n)) 18790 (setq h (+ h n))
18791 (setq n (* dm (org-no-warnings (signum n))))
18792 (when (not (= 0 (setq rem (% m dm))))
18793 (setq m (+ m (if (> n 0) (- rem) (- dm rem)))))
18141 (setq m (+ m n))) 18794 (setq m (+ m n)))
18142 (if (< m 0) (setq m (+ m 60) h (1- h))) 18795 (if (< m 0) (setq m (+ m 60) h (1- h)))
18143 (if (> m 59) (setq m (- m 60) h (1+ h))) 18796 (if (> m 59) (setq m (- m 60) h (1+ h)))
@@ -18146,8 +18799,13 @@ in the timestamp determines what will be changed."
18146 ((org-pos-in-match-range pos 6) 18799 ((org-pos-in-match-range pos 6)
18147 (setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx)))) 18800 (setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx))))
18148 ((org-pos-in-match-range pos 5) 18801 ((org-pos-in-match-range pos 5)
18149 (setq ng 5 new (format "%d" (max 1 (+ n (string-to-number (match-string 5 s)))))))) 18802 (setq ng 5 new (format "%d" (max 1 (+ n (string-to-number (match-string 5 s)))))))
18150 18803
18804 ((org-pos-in-match-range pos 9)
18805 (setq ng 9 new (car (rassoc (+ n (cdr (assoc (match-string 9 s) idx))) idx))))
18806 ((org-pos-in-match-range pos 8)
18807 (setq ng 8 new (format "%d" (max 0 (+ n (string-to-number (match-string 8 s))))))))
18808
18151 (when ng 18809 (when ng
18152 (setq s (concat 18810 (setq s (concat
18153 (substring s 0 (match-beginning ng)) 18811 (substring s 0 (match-beginning ng))
@@ -18203,30 +18861,36 @@ If there is already a time stamp at the cursor position, update it."
18203 (org-insert-time-stamp 18861 (org-insert-time-stamp
18204 (encode-time 0 0 0 (nth 1 cal-date) (car cal-date) (nth 2 cal-date)))))) 18862 (encode-time 0 0 0 (nth 1 cal-date) (car cal-date) (nth 2 cal-date))))))
18205 18863
18206;; Make appt aware of appointments from the agenda 18864(defvar appt-time-msg-list)
18865
18207;;;###autoload 18866;;;###autoload
18208(defun org-agenda-to-appt (&optional filter) 18867(defun org-agenda-to-appt (&optional refresh filter)
18209 "Activate appointments found in `org-agenda-files'. 18868 "Activate appointments found in `org-agenda-files'.
18210When prefixed, prompt for a regular expression and use it as a 18869With a \\[universal-argument] prefix, refresh the list of
18211filter: only add entries if they match this regular expression. 18870appointements.
18212 18871
18213FILTER can be a string. In this case, use this string as a 18872If FILTER is t, interactively prompt the user for a regular
18214regular expression to filter results. 18873expression, and filter out entries that don't match it.
18215 18874
18216FILTER can also be an alist, with the car of each cell being 18875If FILTER is a string, use this string as a regular expression
18876for filtering entries out.
18877
18878FILTER can also be an alist with the car of each cell being
18217either 'headline or 'category. For example: 18879either 'headline or 'category. For example:
18218 18880
18219 '((headline \"IMPORTANT\") 18881 '((headline \"IMPORTANT\")
18220 (category \"Work\")) 18882 (category \"Work\"))
18221 18883
18222will only add headlines containing IMPORTANT or headlines 18884will only add headlines containing IMPORTANT or headlines
18223belonging to the category \"Work\"." 18885belonging to the \"Work\" category."
18224 (interactive "P") 18886 (interactive "P")
18225 (require 'calendar) 18887 (require 'calendar)
18226 (if (equal filter '(4)) 18888 (if refresh (setq appt-time-msg-list nil))
18889 (if (eq filter t)
18227 (setq filter (read-from-minibuffer "Regexp filter: "))) 18890 (setq filter (read-from-minibuffer "Regexp filter: ")))
18228 (let* ((cnt 0) ; count added events 18891 (let* ((cnt 0) ; count added events
18229 (org-agenda-new-buffers nil) 18892 (org-agenda-new-buffers nil)
18893 (org-deadline-warning-days 0)
18230 (today (org-date-to-gregorian 18894 (today (org-date-to-gregorian
18231 (time-to-days (current-time)))) 18895 (time-to-days (current-time))))
18232 (files (org-agenda-files)) entries file) 18896 (files (org-agenda-files)) entries file)
@@ -18235,10 +18899,9 @@ belonging to the category \"Work\"."
18235 (setq entries 18899 (setq entries
18236 (append entries 18900 (append entries
18237 (org-agenda-get-day-entries 18901 (org-agenda-get-day-entries
18238 file today 18902 file today :timestamp :scheduled :deadline))))
18239 :timestamp :scheduled :deadline))))
18240 (setq entries (delq nil entries)) 18903 (setq entries (delq nil entries))
18241 ;; Map thru entries and find if they pass thru the filter 18904 ;; Map thru entries and find if we should filter them out
18242 (mapc 18905 (mapc
18243 (lambda(x) 18906 (lambda(x)
18244 (let* ((evt (org-trim (get-text-property 1 'txt x))) 18907 (let* ((evt (org-trim (get-text-property 1 'txt x)))
@@ -18262,7 +18925,9 @@ belonging to the category \"Work\"."
18262 (appt-add tod evt) 18925 (appt-add tod evt)
18263 (setq cnt (1+ cnt))))) entries) 18926 (setq cnt (1+ cnt))))) entries)
18264 (org-release-buffers org-agenda-new-buffers) 18927 (org-release-buffers org-agenda-new-buffers)
18265 (message "Added %d event%s for today" cnt (if (> cnt 1) "s" "")))) 18928 (if (eq cnt 0)
18929 (message "No event to add")
18930 (message "Added %d event%s for today" cnt (if (> cnt 1) "s" "")))))
18266 18931
18267;;; The clock for measuring work time. 18932;;; The clock for measuring work time.
18268 18933
@@ -18403,9 +19068,7 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
18403 s (- s (* 60 s))) 19068 s (- s (* 60 s)))
18404 (insert " => " (format "%2d:%02d" h m)) 19069 (insert " => " (format "%2d:%02d" h m))
18405 (move-marker org-clock-marker nil) 19070 (move-marker org-clock-marker nil)
18406 (let* ((logging (save-match-data (org-entry-get nil "LOGGING" t))) 19071 (when org-log-note-clock-out
18407 (org-log-done (org-parse-local-options logging 'org-log-done))
18408 (org-log-repeat (org-parse-local-options logging 'org-log-repeat)))
18409 (org-add-log-maybe 'clock-out)) 19072 (org-add-log-maybe 'clock-out))
18410 (when org-mode-line-timer 19073 (when org-mode-line-timer
18411 (cancel-timer org-mode-line-timer) 19074 (cancel-timer org-mode-line-timer)
@@ -18540,7 +19203,7 @@ will be easy to remove."
18540 (make-string (+ off (max 0 (- c (current-column)))) ?.) 19203 (make-string (+ off (max 0 (- c (current-column)))) ?.)
18541 (org-add-props (format "%s %2d:%02d%s" 19204 (org-add-props (format "%s %2d:%02d%s"
18542 (make-string l ?*) h m 19205 (make-string l ?*) h m
18543 (make-string (- 10 l) ?\ )) 19206 (make-string (- 16 l) ?\ ))
18544 '(face secondary-selection)) 19207 '(face secondary-selection))
18545 "")) 19208 ""))
18546 (if (not (featurep 'xemacs)) 19209 (if (not (featurep 'xemacs))
@@ -18572,10 +19235,7 @@ and is only done if the variable `org-clock-out-when-done' is not nil."
18572 (> (save-excursion (outline-next-heading) (point)) 19235 (> (save-excursion (outline-next-heading) (point))
18573 org-clock-marker)) 19236 org-clock-marker))
18574 ;; Clock out, but don't accept a logging message for this. 19237 ;; Clock out, but don't accept a logging message for this.
18575 (let ((org-log-done (if (and (listp org-log-done) 19238 (let ((org-log-note-clock-out nil))
18576 (member 'clock-out org-log-done))
18577 '(done)
18578 org-log-done)))
18579 (org-clock-out)))) 19239 (org-clock-out))))
18580 19240
18581(add-hook 'org-after-todo-state-change-hook 19241(add-hook 'org-after-todo-state-change-hook
@@ -18599,7 +19259,9 @@ When called with a prefix argument, move to the first clock table in the
18599buffer and update it." 19259buffer and update it."
18600 (interactive "P") 19260 (interactive "P")
18601 (org-remove-clock-overlays) 19261 (org-remove-clock-overlays)
18602 (when arg (org-find-dblock "clocktable")) 19262 (when arg
19263 (org-find-dblock "clocktable")
19264 (org-show-entry))
18603 (if (org-in-clocktable-p) 19265 (if (org-in-clocktable-p)
18604 (goto-char (org-in-clocktable-p)) 19266 (goto-char (org-in-clocktable-p))
18605 (org-create-dblock (list :name "clocktable" 19267 (org-create-dblock (list :name "clocktable"
@@ -18690,20 +19352,150 @@ the returned times will be formatted strings."
18690 19352
18691(defun org-dblock-write:clocktable (params) 19353(defun org-dblock-write:clocktable (params)
18692 "Write the standard clocktable." 19354 "Write the standard clocktable."
18693 (let ((hlchars '((1 . "*") (2 . "/"))) 19355 (catch 'exit
18694 (emph nil) 19356 (let* ((hlchars '((1 . "*") (2 . "/")))
18695 (ins (make-marker)) 19357 (ins (make-marker))
18696 (total-time nil) 19358 (total-time nil)
18697 ipos time h m p level hlc hdl maxlevel 19359 (scope (plist-get params :scope))
18698 ts te cc block beg end pos scope tbl tostring multifile) 19360 (tostring (plist-get params :tostring))
18699 (setq scope (plist-get params :scope) 19361 (multifile (plist-get params :multifile))
18700 tostring (plist-get params :tostring) 19362 (header (plist-get params :header))
18701 multifile (plist-get params :multifile) 19363 (maxlevel (or (plist-get params :maxlevel) 3))
18702 maxlevel (or (plist-get params :maxlevel) 3) 19364 (step (plist-get params :step))
18703 emph (plist-get params :emphasize) 19365 (emph (plist-get params :emphasize))
18704 ts (plist-get params :tstart) 19366 (ts (plist-get params :tstart))
18705 te (plist-get params :tend) 19367 (te (plist-get params :tend))
18706 block (plist-get params :block)) 19368 (block (plist-get params :block))
19369 (link (plist-get params :link))
19370 ipos time h m p level hlc hdl
19371 cc beg end pos tbl)
19372 (when step
19373 (org-clocktable-steps params)
19374 (throw 'exit nil))
19375 (when block
19376 (setq cc (org-clock-special-range block nil t)
19377 ts (car cc) te (cdr cc)))
19378 (if ts (setq ts (time-to-seconds
19379 (apply 'encode-time (org-parse-time-string ts)))))
19380 (if te (setq te (time-to-seconds
19381 (apply 'encode-time (org-parse-time-string te)))))
19382 (move-marker ins (point))
19383 (setq ipos (point))
19384
19385 ;; Get the right scope
19386 (setq pos (point))
19387 (save-restriction
19388 (cond
19389 ((not scope))
19390 ((eq scope 'file) (widen))
19391 ((eq scope 'subtree) (org-narrow-to-subtree))
19392 ((eq scope 'tree)
19393 (while (org-up-heading-safe))
19394 (org-narrow-to-subtree))
19395 ((and (symbolp scope) (string-match "^tree\\([0-9]+\\)$"
19396 (symbol-name scope)))
19397 (setq level (string-to-number (match-string 1 (symbol-name scope))))
19398 (catch 'exit
19399 (while (org-up-heading-safe)
19400 (looking-at outline-regexp)
19401 (if (<= (org-reduced-level (funcall outline-level)) level)
19402 (throw 'exit nil))))
19403 (org-narrow-to-subtree))
19404 ((or (listp scope) (eq scope 'agenda))
19405 (let* ((files (if (listp scope) scope (org-agenda-files)))
19406 (scope 'agenda)
19407 (p1 (copy-sequence params))
19408 file)
19409 (plist-put p1 :tostring t)
19410 (plist-put p1 :multifile t)
19411 (plist-put p1 :scope 'file)
19412 (org-prepare-agenda-buffers files)
19413 (while (setq file (pop files))
19414 (with-current-buffer (find-buffer-visiting file)
19415 (push (org-clocktable-add-file
19416 file (org-dblock-write:clocktable p1)) tbl)
19417 (setq total-time (+ (or total-time 0)
19418 org-clock-file-total-minutes)))))))
19419 (goto-char pos)
19420
19421 (unless (eq scope 'agenda)
19422 (org-clock-sum ts te)
19423 (goto-char (point-min))
19424 (while (setq p (next-single-property-change (point) :org-clock-minutes))
19425 (goto-char p)
19426 (when (setq time (get-text-property p :org-clock-minutes))
19427 (save-excursion
19428 (beginning-of-line 1)
19429 (when (and (looking-at (org-re "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@:]+:\\)?[ \t]*$"))
19430 (setq level (org-reduced-level
19431 (- (match-end 1) (match-beginning 1))))
19432 (<= level maxlevel))
19433 (setq hlc (if emph (or (cdr (assoc level hlchars)) "") "")
19434 hdl (if (not link)
19435 (match-string 2)
19436 (org-make-link-string
19437 (format "file:%s::%s"
19438 (buffer-file-name)
19439 (save-match-data
19440 (org-make-org-heading-search-string
19441 (match-string 2))))
19442 (match-string 2)))
19443 h (/ time 60)
19444 m (- time (* 60 h)))
19445 (if (and (not multifile) (= level 1)) (push "|-" tbl))
19446 (push (concat
19447 "| " (int-to-string level) "|" hlc hdl hlc " |"
19448 (make-string (1- level) ?|)
19449 hlc (format "%d:%02d" h m) hlc
19450 " |") tbl))))))
19451 (setq tbl (nreverse tbl))
19452 (if tostring
19453 (if tbl (mapconcat 'identity tbl "\n") nil)
19454 (goto-char ins)
19455 (insert-before-markers
19456 (or header
19457 (concat
19458 "Clock summary at ["
19459 (substring
19460 (format-time-string (cdr org-time-stamp-formats))
19461 1 -1)
19462 "]."
19463 (if block
19464 (format " Considered range is /%s/." block)
19465 "")
19466 "\n\n"))
19467 (if (eq scope 'agenda) "|File" "")
19468 "|L|Headline|Time|\n")
19469 (setq total-time (or total-time org-clock-file-total-minutes)
19470 h (/ total-time 60)
19471 m (- total-time (* 60 h)))
19472 (insert-before-markers
19473 "|-\n|"
19474 (if (eq scope 'agenda) "|" "")
19475 "|"
19476 "*Total time*| "
19477 (format "*%d:%02d*" h m)
19478 "|\n|-\n")
19479 (setq tbl (delq nil tbl))
19480 (if (and (stringp (car tbl)) (> (length (car tbl)) 1)
19481 (equal (substring (car tbl) 0 2) "|-"))
19482 (pop tbl))
19483 (insert-before-markers (mapconcat
19484 'identity (delq nil tbl)
19485 (if (eq scope 'agenda) "\n|-\n" "\n")))
19486 (backward-delete-char 1)
19487 (goto-char ipos)
19488 (skip-chars-forward "^|")
19489 (org-table-align))))))
19490
19491(defun org-clocktable-steps (params)
19492 (let* ((p1 (copy-sequence params))
19493 (ts (plist-get p1 :tstart))
19494 (te (plist-get p1 :tend))
19495 (step0 (plist-get p1 :step))
19496 (step (cdr (assoc step0 '((day . 86400) (week . 604800)))))
19497 (block (plist-get p1 :block))
19498 cc)
18707 (when block 19499 (when block
18708 (setq cc (org-clock-special-range block nil t) 19500 (setq cc (org-clock-special-range block nil t)
18709 ts (car cc) te (cdr cc))) 19501 ts (car cc) te (cdr cc)))
@@ -18711,104 +19503,23 @@ the returned times will be formatted strings."
18711 (apply 'encode-time (org-parse-time-string ts))))) 19503 (apply 'encode-time (org-parse-time-string ts)))))
18712 (if te (setq te (time-to-seconds 19504 (if te (setq te (time-to-seconds
18713 (apply 'encode-time (org-parse-time-string te))))) 19505 (apply 'encode-time (org-parse-time-string te)))))
18714 (move-marker ins (point)) 19506 (plist-put p1 :header "")
18715 (setq ipos (point)) 19507 (plist-put p1 :step nil)
18716 19508 (plist-put p1 :block nil)
18717 ;; Get the right scope 19509 (while (< ts te)
18718 (setq pos (point)) 19510 (or (bolp) (insert "\n"))
18719 (save-restriction 19511 (plist-put p1 :tstart (format-time-string
18720 (cond 19512 (car org-time-stamp-formats)
18721 ((not scope)) 19513 (seconds-to-time ts)))
18722 ((eq scope 'file) (widen)) 19514 (plist-put p1 :tend (format-time-string
18723 ((eq scope 'subtree) (org-narrow-to-subtree)) 19515 (car org-time-stamp-formats)
18724 ((eq scope 'tree) 19516 (seconds-to-time (setq ts (+ ts step)))))
18725 (while (org-up-heading-safe)) 19517 (insert "\n" (if (eq step0 'day) "Daily report: " "Weekly report starting on: ")
18726 (org-narrow-to-subtree)) 19518 (plist-get p1 :tstart) "\n")
18727 ((and (symbolp scope) (string-match "^tree\\([0-9]+\\)$" 19519 (org-dblock-write:clocktable p1)
18728 (symbol-name scope))) 19520 (re-search-forward "#\\+END:")
18729 (setq level (string-to-number (match-string 1 (symbol-name scope)))) 19521 (end-of-line 0))))
18730 (catch 'exit
18731 (while (org-up-heading-safe)
18732 (looking-at outline-regexp)
18733 (if (<= (org-reduced-level (funcall outline-level)) level)
18734 (throw 'exit nil))))
18735 (org-narrow-to-subtree))
18736 ((or (listp scope) (eq scope 'agenda))
18737 (let* ((files (if (listp scope) scope (org-agenda-files)))
18738 (scope 'agenda)
18739 (p1 (copy-sequence params))
18740 file)
18741 (plist-put p1 :tostring t)
18742 (plist-put p1 :multifile t)
18743 (plist-put p1 :scope 'file)
18744 (org-prepare-agenda-buffers files)
18745 (while (setq file (pop files))
18746 (with-current-buffer (find-buffer-visiting file)
18747 (push (org-clocktable-add-file
18748 file (org-dblock-write:clocktable p1)) tbl)
18749 (setq total-time (+ (or total-time 0)
18750 org-clock-file-total-minutes)))))))
18751 (goto-char pos)
18752 19522
18753 (unless (eq scope 'agenda)
18754 (org-clock-sum ts te)
18755 (goto-char (point-min))
18756 (while (setq p (next-single-property-change (point) :org-clock-minutes))
18757 (goto-char p)
18758 (when (setq time (get-text-property p :org-clock-minutes))
18759 (save-excursion
18760 (beginning-of-line 1)
18761 (when (and (looking-at (org-re "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@:]+:\\)?[ \t]*$"))
18762 (setq level (org-reduced-level
18763 (- (match-end 1) (match-beginning 1))))
18764 (<= level maxlevel))
18765 (setq hlc (if emph (or (cdr (assoc level hlchars)) "") "")
18766 hdl (match-string 2)
18767 h (/ time 60)
18768 m (- time (* 60 h)))
18769 (if (and (not multifile) (= level 1)) (push "|-" tbl))
18770 (push (concat
18771 "| " (int-to-string level) "|" hlc hdl hlc " |"
18772 (make-string (1- level) ?|)
18773 hlc (format "%d:%02d" h m) hlc
18774 " |") tbl))))))
18775 (setq tbl (nreverse tbl))
18776 (if tostring
18777 (if tbl (mapconcat 'identity tbl "\n") nil)
18778 (goto-char ins)
18779 (insert-before-markers
18780 "Clock summary at ["
18781 (substring
18782 (format-time-string (cdr org-time-stamp-formats))
18783 1 -1)
18784 "]."
18785 (if block
18786 (format " Considered range is /%s/." block)
18787 "")
18788 "\n\n"
18789 (if (eq scope 'agenda) "|File" "")
18790 "|L|Headline|Time|\n")
18791 (setq total-time (or total-time org-clock-file-total-minutes)
18792 h (/ total-time 60)
18793 m (- total-time (* 60 h)))
18794 (insert-before-markers
18795 "|-\n|"
18796 (if (eq scope 'agenda) "|" "")
18797 "|"
18798 "*Total time*| "
18799 (format "*%d:%02d*" h m)
18800 "|\n|-\n")
18801 (setq tbl (delq nil tbl))
18802 (if (and (stringp (car tbl)) (> (length (car tbl)) 1)
18803 (equal (substring (car tbl) 0 2) "|-"))
18804 (pop tbl))
18805 (insert-before-markers (mapconcat
18806 'identity (delq nil tbl)
18807 (if (eq scope 'agenda) "\n|-\n" "\n")))
18808 (backward-delete-char 1)
18809 (goto-char ipos)
18810 (skip-chars-forward "^|")
18811 (org-table-align)))))
18812 19523
18813(defun org-clocktable-add-file (file table) 19524(defun org-clocktable-add-file (file table)
18814 (if table 19525 (if table
@@ -18872,6 +19583,7 @@ FIXME: describe the elements."
18872(defvar org-agenda-follow-mode nil) 19583(defvar org-agenda-follow-mode nil)
18873(defvar org-agenda-show-log nil) 19584(defvar org-agenda-show-log nil)
18874(defvar org-agenda-redo-command nil) 19585(defvar org-agenda-redo-command nil)
19586(defvar org-agenda-query-string nil)
18875(defvar org-agenda-mode-hook nil) 19587(defvar org-agenda-mode-hook nil)
18876(defvar org-agenda-type nil) 19588(defvar org-agenda-type nil)
18877(defvar org-agenda-force-single-file nil) 19589(defvar org-agenda-force-single-file nil)
@@ -19008,6 +19720,11 @@ The following commands are available:
19008(org-defkey org-agenda-mode-map [(left)] 'org-agenda-earlier) 19720(org-defkey org-agenda-mode-map [(left)] 'org-agenda-earlier)
19009(org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns) 19721(org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns)
19010 19722
19723(org-defkey org-agenda-mode-map "[" 'org-agenda-manipulate-query-add)
19724(org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract)
19725(org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
19726(org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
19727
19011(defvar org-agenda-keymap (copy-keymap org-agenda-mode-map) 19728(defvar org-agenda-keymap (copy-keymap org-agenda-mode-map)
19012 "Local keymap for agenda entries from Org-mode.") 19729 "Local keymap for agenda entries from Org-mode.")
19013 19730
@@ -19272,6 +19989,8 @@ Pressing `<' twice means to restrict to the current subtree or region
19272 (org-let lprops '(org-agenda-list current-prefix-arg))) 19989 (org-let lprops '(org-agenda-list current-prefix-arg)))
19273 ((eq type 'alltodo) 19990 ((eq type 'alltodo)
19274 (org-let lprops '(org-todo-list current-prefix-arg))) 19991 (org-let lprops '(org-todo-list current-prefix-arg)))
19992 ((eq type 'search)
19993 (org-let lprops '(org-search-view current-prefix-arg match)))
19275 ((eq type 'stuck) 19994 ((eq type 'stuck)
19276 (org-let lprops '(org-agenda-list-stuck-projects 19995 (org-let lprops '(org-agenda-list-stuck-projects
19277 current-prefix-arg))) 19996 current-prefix-arg)))
@@ -19302,6 +20021,7 @@ Pressing `<' twice means to restrict to the current subtree or region
19302 (setq org-agenda-custom-commands org-agenda-custom-commands-orig) 20021 (setq org-agenda-custom-commands org-agenda-custom-commands-orig)
19303 (customize-variable 'org-agenda-custom-commands)) 20022 (customize-variable 'org-agenda-custom-commands))
19304 ((equal keys "a") (call-interactively 'org-agenda-list)) 20023 ((equal keys "a") (call-interactively 'org-agenda-list))
20024 ((equal keys "s") (call-interactively 'org-search-view))
19305 ((equal keys "t") (call-interactively 'org-todo-list)) 20025 ((equal keys "t") (call-interactively 'org-todo-list))
19306 ((equal keys "T") (org-call-with-arg 'org-todo-list (or arg '(4)))) 20026 ((equal keys "T") (org-call-with-arg 'org-todo-list (or arg '(4))))
19307 ((equal keys "m") (call-interactively 'org-tags-view)) 20027 ((equal keys "m") (call-interactively 'org-tags-view))
@@ -19351,7 +20071,8 @@ a Agenda for current week or day e Export agenda views
19351t List of all TODO entries T Entries with special TODO kwd 20071t List of all TODO entries T Entries with special TODO kwd
19352m Match a TAGS query M Like m, but only TODO entries 20072m Match a TAGS query M Like m, but only TODO entries
19353L Timeline for current buffer # List stuck projects (!=configure) 20073L Timeline for current buffer # List stuck projects (!=configure)
19354/ Multi-occur C Configure custom agenda commands 20074s Search for keywords C Configure custom agenda commands
20075/ Multi-occur
19355") 20076")
19356 (start 0)) 20077 (start 0))
19357 (while (string-match 20078 (while (string-match
@@ -19388,6 +20109,7 @@ L Timeline for current buffer # List stuck projects (!=configure)
19388 ((string-match "\\S-" desc) desc) 20109 ((string-match "\\S-" desc) desc)
19389 ((eq type 'agenda) "Agenda for current week or day") 20110 ((eq type 'agenda) "Agenda for current week or day")
19390 ((eq type 'alltodo) "List of all TODO entries") 20111 ((eq type 'alltodo) "List of all TODO entries")
20112 ((eq type 'search) "Word search")
19391 ((eq type 'stuck) "List of stuck projects") 20113 ((eq type 'stuck) "List of stuck projects")
19392 ((eq type 'todo) "TODO keyword") 20114 ((eq type 'todo) "TODO keyword")
19393 ((eq type 'tags) "Tags query") 20115 ((eq type 'tags) "Tags query")
@@ -19468,7 +20190,7 @@ L Timeline for current buffer # List stuck projects (!=configure)
19468 ((eq c ?>) 20190 ((eq c ?>)
19469 (org-agenda-remove-restriction-lock 'noupdate) 20191 (org-agenda-remove-restriction-lock 'noupdate)
19470 (setq restriction nil)) 20192 (setq restriction nil))
19471 ((and (equal selstring "") (memq c '(?a ?t ?m ?L ?C ?e ?T ?M ?# ?! ?/))) 20193 ((and (equal selstring "") (memq c '(?s ?a ?t ?m ?L ?C ?e ?T ?M ?# ?! ?/)))
19472 (throw 'exit (cons (setq selstring (char-to-string c)) restriction))) 20194 (throw 'exit (cons (setq selstring (char-to-string c)) restriction)))
19473 ((and (> (length selstring) 0) (eq c ?\d)) 20195 ((and (> (length selstring) 0) (eq c ?\d))
19474 (delete-window) 20196 (delete-window)
@@ -19494,6 +20216,9 @@ L Timeline for current buffer # List stuck projects (!=configure)
19494 ((eq type 'alltodo) 20216 ((eq type 'alltodo)
19495 (org-let2 gprops lprops 20217 (org-let2 gprops lprops
19496 '(call-interactively 'org-todo-list))) 20218 '(call-interactively 'org-todo-list)))
20219 ((eq type 'search)
20220 (org-let2 gprops lprops
20221 '(org-search-view current-prefix-arg match)))
19497 ((eq type 'stuck) 20222 ((eq type 'stuck)
19498 (org-let2 gprops lprops 20223 (org-let2 gprops lprops
19499 '(call-interactively 'org-agenda-list-stuck-projects))) 20224 '(call-interactively 'org-agenda-list-stuck-projects)))
@@ -19681,6 +20406,9 @@ so the export commands can easily use it."
19681 "Write the current buffer (an agenda view) as a file. 20406 "Write the current buffer (an agenda view) as a file.
19682Depending on the extension of the file name, plain text (.txt), 20407Depending on the extension of the file name, plain text (.txt),
19683HTML (.html or .htm) or Postscript (.ps) is produced. 20408HTML (.html or .htm) or Postscript (.ps) is produced.
20409If the extension is .ics, run icalendar export over all files used
20410to construct the agenda and limit the export to entries listed in the
20411agenda now.
19684If NOSETTINGS is given, do not scope the settings of 20412If NOSETTINGS is given, do not scope the settings of
19685`org-agenda-exporter-settings' into the export commands. This is used when 20413`org-agenda-exporter-settings' into the export commands. This is used when
19686the settings have already been scoped and we do not wish to overrule other, 20414the settings have already been scoped and we do not wish to overrule other,
@@ -19711,6 +20439,13 @@ higher priority settings."
19711 ((string-match "\\.ps\\'" file) 20439 ((string-match "\\.ps\\'" file)
19712 (ps-print-buffer-with-faces file) 20440 (ps-print-buffer-with-faces file)
19713 (message "Postscript written to %s" file)) 20441 (message "Postscript written to %s" file))
20442 ((string-match "\\.ics\\'" file)
20443 (let ((org-agenda-marker-table
20444 (org-create-marker-find-array
20445 (org-agenda-collect-markers)))
20446 (org-icalendar-verify-function 'org-check-agenda-marker-table)
20447 (org-combined-agenda-icalendar-file file))
20448 (apply 'org-export-icalendar 'combine (org-agenda-files))))
19714 (t 20449 (t
19715 (let ((bs (buffer-string))) 20450 (let ((bs (buffer-string)))
19716 (find-file file) 20451 (find-file file)
@@ -19720,6 +20455,43 @@ higher priority settings."
19720 (message "Plain text written to %s" file)))))) 20455 (message "Plain text written to %s" file))))))
19721 (set-buffer org-agenda-buffer-name))) 20456 (set-buffer org-agenda-buffer-name)))
19722 20457
20458(defun org-agenda-collect-markers ()
20459 "Collect the markers pointing to entries in the agenda buffer."
20460 (let (m markers)
20461 (save-excursion
20462 (goto-char (point-min))
20463 (while (not (eobp))
20464 (when (setq m (or (get-text-property (point) 'org-hd-marker)
20465 (get-text-property (point) 'org-marker)))
20466 (push m markers))
20467 (beginning-of-line 2)))
20468 (nreverse markers)))
20469
20470(defun org-create-marker-find-array (marker-list)
20471 "Create a alist of files names with all marker positions in that file."
20472 (let (f tbl m a p)
20473 (while (setq m (pop marker-list))
20474 (setq p (marker-position m)
20475 f (buffer-file-name (or (buffer-base-buffer
20476 (marker-buffer m))
20477 (marker-buffer m))))
20478 (if (setq a (assoc f tbl))
20479 (push (marker-position m) (cdr a))
20480 (push (list f p) tbl)))
20481 (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
20482 tbl)))
20483
20484(defvar org-agenda-marker-table nil) ; dyamically scoped parameter
20485(defun org-check-agenda-marker-table ()
20486 "Check of the current entry is on the marker list."
20487 (let ((file (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
20488 a)
20489 (and (setq a (assoc file org-agenda-marker-table))
20490 (save-match-data
20491 (save-excursion
20492 (org-back-to-heading t)
20493 (member (point) (cdr a)))))))
20494
19723(defmacro org-no-read-only (&rest body) 20495(defmacro org-no-read-only (&rest body)
19724 "Inhibit read-only for BODY." 20496 "Inhibit read-only for BODY."
19725 `(let ((inhibit-read-only t)) ,@body)) 20497 `(let ((inhibit-read-only t)) ,@body))
@@ -19904,7 +20676,7 @@ Optional argument FILE means, use this file instead of the current."
19904 (unless (or (bobp) org-agenda-compact-blocks) 20676 (unless (or (bobp) org-agenda-compact-blocks)
19905 (insert "\n" (make-string (window-width) ?=) "\n")) 20677 (insert "\n" (make-string (window-width) ?=) "\n"))
19906 (narrow-to-region (point) (point-max))) 20678 (narrow-to-region (point) (point-max)))
19907 (org-agenda-maybe-reset-markers 'force) 20679 (org-agenda-reset-markers)
19908 (org-prepare-agenda-buffers (org-agenda-files)) 20680 (org-prepare-agenda-buffers (org-agenda-files))
19909 (setq org-todo-keywords-for-agenda 20681 (setq org-todo-keywords-for-agenda
19910 (org-uniquify org-todo-keywords-for-agenda)) 20682 (org-uniquify org-todo-keywords-for-agenda))
@@ -19953,7 +20725,9 @@ Optional argument FILE means, use this file instead of the current."
19953 (org-agenda-columns)) 20725 (org-agenda-columns))
19954 (when org-agenda-fontify-priorities 20726 (when org-agenda-fontify-priorities
19955 (org-fontify-priorities)) 20727 (org-fontify-priorities))
19956 (run-hooks 'org-finalize-agenda-hook)))) 20728 (run-hooks 'org-finalize-agenda-hook)
20729 (setq org-agenda-type (get-text-property (point) 'org-agenda-type))
20730 )))
19957 20731
19958(defun org-fontify-priorities () 20732(defun org-fontify-priorities ()
19959 "Make highest priority lines bold, and lowest italic." 20733 "Make highest priority lines bold, and lowest italic."
@@ -20066,14 +20840,10 @@ no longer in use."
20066 (push m org-agenda-markers) 20840 (push m org-agenda-markers)
20067 m)) 20841 m))
20068 20842
20069(defun org-agenda-maybe-reset-markers (&optional force) 20843(defun org-agenda-reset-markers ()
20070 "Reset markers created by `org-agenda'. But only if they are old enough." 20844 "Reset markers created by `org-agenda'."
20071 (if (or (and force (not org-agenda-multi)) 20845 (while org-agenda-markers
20072 (> (- (time-to-seconds (current-time)) 20846 (move-marker (pop org-agenda-markers) nil)))
20073 org-agenda-last-marker-time)
20074 5))
20075 (while org-agenda-markers
20076 (move-marker (pop org-agenda-markers) nil))))
20077 20847
20078(defun org-get-agenda-file-buffer (file) 20848(defun org-get-agenda-file-buffer (file)
20079 "Get a buffer visiting FILE. If the buffer needs to be created, add 20849 "Get a buffer visiting FILE. If the buffer needs to be created, add
@@ -20190,14 +20960,16 @@ dates."
20190 (org-finalize-agenda) 20960 (org-finalize-agenda)
20191 (setq buffer-read-only t))) 20961 (setq buffer-read-only t)))
20192 20962
20193(defun org-get-all-dates (beg end &optional no-ranges force-today inactive empty) 20963(defun org-get-all-dates (beg end &optional no-ranges force-today inactive empty pre-re)
20194 "Return a list of all relevant day numbers from BEG to END buffer positions. 20964 "Return a list of all relevant day numbers from BEG to END buffer positions.
20195If NO-RANGES is non-nil, include only the start and end dates of a range, 20965If NO-RANGES is non-nil, include only the start and end dates of a range,
20196not every single day in the range. If FORCE-TODAY is non-nil, make 20966not every single day in the range. If FORCE-TODAY is non-nil, make
20197sure that TODAY is included in the list. If INACTIVE is non-nil, also 20967sure that TODAY is included in the list. If INACTIVE is non-nil, also
20198inactive time stamps (those in square brackets) are included. 20968inactive time stamps (those in square brackets) are included.
20199When EMPTY is non-nil, also include days without any entries." 20969When EMPTY is non-nil, also include days without any entries."
20200 (let ((re (if inactive org-ts-regexp-both org-ts-regexp)) 20970 (let ((re (concat
20971 (if pre-re pre-re "")
20972 (if inactive org-ts-regexp-both org-ts-regexp)))
20201 dates dates1 date day day1 day2 ts1 ts2) 20973 dates dates1 date day day1 day2 ts1 ts2)
20202 (if force-today 20974 (if force-today
20203 (setq dates (list (time-to-days (current-time))))) 20975 (setq dates (list (time-to-days (current-time)))))
@@ -20239,7 +21011,7 @@ When EMPTY is non-nil, also include days without any entries."
20239(defvar org-starting-day nil) ; local variable in the agenda buffer 21011(defvar org-starting-day nil) ; local variable in the agenda buffer
20240(defvar org-agenda-span nil) ; local variable in the agenda buffer 21012(defvar org-agenda-span nil) ; local variable in the agenda buffer
20241(defvar org-include-all-loc nil) ; local variable 21013(defvar org-include-all-loc nil) ; local variable
20242(defvar org-agenda-remove-date nil) ; dynamically scoped 21014(defvar org-agenda-remove-date nil) ; dynamically scoped FIXME: not used???
20243 21015
20244;;;###autoload 21016;;;###autoload
20245(defun org-agenda-list (&optional include-all start-day ndays) 21017(defun org-agenda-list (&optional include-all start-day ndays)
@@ -20396,6 +21168,163 @@ given in `org-agenda-start-on-weekday'."
20396(defun org-agenda-ndays-to-span (n) 21168(defun org-agenda-ndays-to-span (n)
20397 (cond ((< n 7) 'day) ((= n 7) 'week) ((< n 32) 'month) (t 'year))) 21169 (cond ((< n 7) 'day) ((= n 7) 'week) ((< n 32) 'month) (t 'year)))
20398 21170
21171;;; Agenda word search
21172
21173(defvar org-agenda-search-history nil)
21174
21175;;;###autoload
21176(defun org-search-view (&optional arg string)
21177 "Show all entries that contain words or regular expressions.
21178If the first character of the search string is an asterisks,
21179search only the headlines.
21180
21181The search string is broken into \"words\" by splitting at whitespace.
21182The individual words are then interpreted as a boolean expression with
21183logical AND. Words prefixed with a minus must not occur in the entry.
21184Words without a prefix or prefixed with a plus must occur in the entry.
21185Matching is case-insensitive and the words are enclosed by word delimiters.
21186
21187Words enclosed by curly braces are interpreted as regular expressions
21188that must or must not match in the entry.
21189
21190This command searches the agenda files, and in addition the files listed
21191in `org-agenda-text-search-extra-files'."
21192 (interactive "P")
21193 (org-compile-prefix-format 'search)
21194 (org-set-sorting-strategy 'search)
21195 (org-prepare-agenda "SEARCH")
21196 (let* ((props (list 'face nil
21197 'done-face 'org-done
21198 'org-not-done-regexp org-not-done-regexp
21199 'org-todo-regexp org-todo-regexp
21200 'mouse-face 'highlight
21201 'keymap org-agenda-keymap
21202 'help-echo (format "mouse-2 or RET jump to location")))
21203 regexp rtn rtnall files file pos
21204 marker priority category tags c neg re
21205 ee txt beg end words regexps+ regexps- hdl-only buffer beg1 str)
21206 (unless (and (not arg)
21207 (stringp string)
21208 (string-match "\\S-" string))
21209 (setq string (read-string "[+-]Word/{Regexp} ...: "
21210 (cond
21211 ((integerp arg) (cons string arg))
21212 (arg string))
21213 'org-agenda-search-history)))
21214 (setq org-agenda-redo-command
21215 (list 'org-search-view 'current-prefix-arg string))
21216 (setq org-agenda-query-string string)
21217
21218 (if (equal (string-to-char string) ?*)
21219 (setq hdl-only t
21220 words (substring string 1))
21221 (setq words string))
21222 (setq words (org-split-string words))
21223 (mapc (lambda (w)
21224 (setq c (string-to-char w))
21225 (if (equal c ?-)
21226 (setq neg t w (substring w 1))
21227 (if (equal c ?+)
21228 (setq neg nil w (substring w 1))
21229 (setq neg nil)))
21230 (if (string-match "\\`{.*}\\'" w)
21231 (setq re (substring w 1 -1))
21232 (setq re (concat "\\<" (regexp-quote (downcase w)) "\\>")))
21233 (if neg (push re regexps-) (push re regexps+)))
21234 words)
21235 (setq regexps+ (sort regexps+ (lambda (a b) (> (length a) (length b)))))
21236 (if (not regexps+)
21237 (setq regexp (concat "^" org-outline-regexp))
21238 (setq regexp (pop regexps+))
21239 (if hdl-only (setq regexp (concat "^" org-outline-regexp ".*?"
21240 regexp))))
21241 (setq files (append (org-agenda-files) org-agenda-text-search-extra-files)
21242 rtnall nil)
21243 (while (setq file (pop files))
21244 (setq ee nil)
21245 (catch 'nextfile
21246 (org-check-agenda-file file)
21247 (setq buffer (if (file-exists-p file)
21248 (org-get-agenda-file-buffer file)
21249 (error "No such file %s" file)))
21250 (if (not buffer)
21251 ;; If file does not exist, make sure an error message is sent
21252 (setq rtn (list (format "ORG-AGENDA-ERROR: No such org-file %s"
21253 file))))
21254 (with-current-buffer buffer
21255 (unless (org-mode-p)
21256 (error "Agenda file %s is not in `org-mode'" file))
21257 (let ((case-fold-search t))
21258 (save-excursion
21259 (save-restriction
21260 (if org-agenda-restrict
21261 (narrow-to-region org-agenda-restrict-begin
21262 org-agenda-restrict-end)
21263 (widen))
21264 (goto-char (point-min))
21265 (unless (or (org-on-heading-p)
21266 (outline-next-heading))
21267 (throw 'nextfile t))
21268 (goto-char (max (point-min) (1- (point))))
21269 (while (re-search-forward regexp nil t)
21270 (org-back-to-heading t)
21271 (skip-chars-forward "* ")
21272 (setq beg (point-at-bol)
21273 beg1 (point)
21274 end (progn (outline-next-heading) (point)))
21275 (catch :skip
21276 (goto-char beg)
21277 (org-agenda-skip)
21278 (setq str (buffer-substring-no-properties
21279 (point-at-bol)
21280 (if hdl-only (point-at-eol) end)))
21281 (mapc (lambda (wr) (when (string-match wr str)
21282 (goto-char (1- end))
21283 (throw :skip t)))
21284 regexps-)
21285 (mapc (lambda (wr) (unless (string-match wr str)
21286 (goto-char (1- end))
21287 (throw :skip t)))
21288 regexps+)
21289 (goto-char beg)
21290 (setq marker (org-agenda-new-marker (point))
21291 category (org-get-category)
21292 tags (org-get-tags-at (point))
21293 txt (org-format-agenda-item
21294 ""
21295 (buffer-substring-no-properties
21296 beg1 (point-at-eol))
21297 category tags))
21298 (org-add-props txt props
21299 'org-marker marker 'org-hd-marker marker
21300 'priority 1000 'org-category category
21301 'type "search")
21302 (push txt ee)
21303 (goto-char (1- end)))))))))
21304 (setq rtn (nreverse ee))
21305 (setq rtnall (append rtnall rtn)))
21306 (if org-agenda-overriding-header
21307 (insert (org-add-props (copy-sequence org-agenda-overriding-header)
21308 nil 'face 'org-agenda-structure) "\n")
21309 (insert "Search words: ")
21310 (add-text-properties (point-min) (1- (point))
21311 (list 'face 'org-agenda-structure))
21312 (setq pos (point))
21313 (insert string "\n")
21314 (add-text-properties pos (1- (point)) (list 'face 'org-warning))
21315 (setq pos (point))
21316 (unless org-agenda-multi
21317 (insert "Press `[', `]' to add/sub word, `{', `}' to add/sub regexp, `C-u r' to edit\n")
21318 (add-text-properties pos (1- (point))
21319 (list 'face 'org-agenda-structure))))
21320 (when rtnall
21321 (insert (org-finalize-agenda-entries rtnall) "\n"))
21322 (goto-char (point-min))
21323 (org-fit-agenda-window)
21324 (add-text-properties (point-min) (point-max) '(org-agenda-type search))
21325 (org-finalize-agenda)
21326 (setq buffer-read-only t)))
21327
20399;;; Agenda TODO list 21328;;; Agenda TODO list
20400 21329
20401(defvar org-select-this-todo-keyword nil) 21330(defvar org-select-this-todo-keyword nil)
@@ -20483,9 +21412,10 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
20483 (setq matcher (org-make-tags-matcher match) 21412 (setq matcher (org-make-tags-matcher match)
20484 match (car matcher) matcher (cdr matcher)) 21413 match (car matcher) matcher (cdr matcher))
20485 (org-prepare-agenda (concat "TAGS " match)) 21414 (org-prepare-agenda (concat "TAGS " match))
21415 (setq org-agenda-query-string match)
20486 (setq org-agenda-redo-command 21416 (setq org-agenda-redo-command
20487 (list 'org-tags-view (list 'quote todo-only) 21417 (list 'org-tags-view (list 'quote todo-only)
20488 (list 'if 'current-prefix-arg nil match))) 21418 (list 'if 'current-prefix-arg nil 'org-agenda-query-string)))
20489 (setq files (org-agenda-files) 21419 (setq files (org-agenda-files)
20490 rtnall nil) 21420 rtnall nil)
20491 (while (setq file (pop files)) 21421 (while (setq file (pop files))
@@ -20805,7 +21735,10 @@ So the example above may also be written as
20805The function expects the lisp variables `entry' and `date' to be provided 21735The function expects the lisp variables `entry' and `date' to be provided
20806by the caller, because this is how the calendar works. Don't use this 21736by the caller, because this is how the calendar works. Don't use this
20807function from a program - use `org-agenda-get-day-entries' instead." 21737function from a program - use `org-agenda-get-day-entries' instead."
20808 (org-agenda-maybe-reset-markers) 21738 (when (> (- (time-to-seconds (current-time))
21739 org-agenda-last-marker-time)
21740 5)
21741 (org-agenda-reset-markers))
20809 (org-compile-prefix-format 'agenda) 21742 (org-compile-prefix-format 'agenda)
20810 (org-set-sorting-strategy 'agenda) 21743 (org-set-sorting-strategy 'agenda)
20811 (setq args (or args '(:deadline :scheduled :timestamp :sexp))) 21744 (setq args (or args '(:deadline :scheduled :timestamp :sexp)))
@@ -21140,7 +22073,7 @@ the documentation of `org-diary'."
21140 'type "closed" 'date date 22073 'type "closed" 'date date
21141 'undone-face 'org-warning 'done-face 'org-done) 22074 'undone-face 'org-warning 'done-face 'org-done)
21142 (push txt ee)) 22075 (push txt ee))
21143 (outline-next-heading))) 22076 (goto-char (point-at-eol))))
21144 (nreverse ee))) 22077 (nreverse ee)))
21145 22078
21146(defun org-agenda-get-deadlines () 22079(defun org-agenda-get-deadlines ()
@@ -21163,10 +22096,10 @@ the documentation of `org-diary'."
21163 (org-agenda-skip) 22096 (org-agenda-skip)
21164 (setq s (match-string 1) 22097 (setq s (match-string 1)
21165 pos (1- (match-beginning 1)) 22098 pos (1- (match-beginning 1))
21166 d2 (org-time-string-to-absolute (match-string 1) d1) 22099 d2 (org-time-string-to-absolute (match-string 1) d1 'past)
21167 diff (- d2 d1) 22100 diff (- d2 d1)
21168 wdays (org-get-wdays s) 22101 wdays (org-get-wdays s)
21169 dfrac (/ (* 1.0 (- wdays diff)) wdays) 22102 dfrac (/ (* 1.0 (- wdays diff)) (max wdays 1))
21170 upcomingp (and todayp (> diff 0))) 22103 upcomingp (and todayp (> diff 0)))
21171 ;; When to show a deadline in the calendar: 22104 ;; When to show a deadline in the calendar:
21172 ;; If the expiration is within wdays warning time. 22105 ;; If the expiration is within wdays warning time.
@@ -21202,11 +22135,11 @@ the documentation of `org-diary'."
21202 head category tags timestr)))) 22135 head category tags timestr))))
21203 (setq txt org-agenda-no-heading-message)) 22136 (setq txt org-agenda-no-heading-message))
21204 (when txt 22137 (when txt
21205 (setq face (org-agenda-deadline-face dfrac)) 22138 (setq face (org-agenda-deadline-face dfrac wdays))
21206 (org-add-props txt props 22139 (org-add-props txt props
21207 'org-marker (org-agenda-new-marker pos) 22140 'org-marker (org-agenda-new-marker pos)
21208 'org-hd-marker (org-agenda-new-marker pos1) 22141 'org-hd-marker (org-agenda-new-marker pos1)
21209 'priority (+ (if upcomingp (floor (* dfrac 10.)) 100) 22142 'priority (+ (- diff)
21210 (org-get-priority txt)) 22143 (org-get-priority txt))
21211 'org-category category 22144 'org-category category
21212 'type (if upcomingp "upcoming-deadline" "deadline") 22145 'type (if upcomingp "upcoming-deadline" "deadline")
@@ -21216,9 +22149,10 @@ the documentation of `org-diary'."
21216 (push txt ee)))))) 22149 (push txt ee))))))
21217 (nreverse ee))) 22150 (nreverse ee)))
21218 22151
21219(defun org-agenda-deadline-face (fraction) 22152(defun org-agenda-deadline-face (fraction &optional wdays)
21220 "Return the face to displaying a deadline item. 22153 "Return the face to displaying a deadline item.
21221FRACTION is what fraction of the head-warning time has passed." 22154FRACTION is what fraction of the head-warning time has passed."
22155 (if (equal wdays 0) (setq fraction 1.))
21222 (let ((faces org-agenda-deadline-faces) f) 22156 (let ((faces org-agenda-deadline-faces) f)
21223 (catch 'exit 22157 (catch 'exit
21224 (while (setq f (pop faces)) 22158 (while (setq f (pop faces))
@@ -21245,7 +22179,10 @@ FRACTION is what fraction of the head-warning time has passed."
21245 (org-agenda-skip) 22179 (org-agenda-skip)
21246 (setq s (match-string 1) 22180 (setq s (match-string 1)
21247 pos (1- (match-beginning 1)) 22181 pos (1- (match-beginning 1))
21248 d2 (org-time-string-to-absolute (match-string 1) d1) 22182 d2 (org-time-string-to-absolute (match-string 1) d1 'past)
22183;;; is this right?
22184;;; do we need to do this for deadleine too????
22185;;; d2 (org-time-string-to-absolute (match-string 1) (if todayp nil d1))
21249 diff (- d2 d1)) 22186 diff (- d2 d1))
21250 (setq pastschedp (and todayp (< diff 0))) 22187 (setq pastschedp (and todayp (< diff 0)))
21251 ;; When to show a scheduled item in the calendar: 22188 ;; When to show a scheduled item in the calendar:
@@ -21626,11 +22563,6 @@ HH:MM."
21626 (insert (format org-agenda-todo-keyword-format s))))) 22563 (insert (format org-agenda-todo-keyword-format s)))))
21627 (setq re (concat (get-text-property 0 'org-todo-regexp x)) 22564 (setq re (concat (get-text-property 0 'org-todo-regexp x))
21628 pl (get-text-property 0 'prefix-length x)) 22565 pl (get-text-property 0 'prefix-length x))
21629; (and re (equal (string-match (concat "\\(\\.*\\)" re) x (or pl 0)) pl)
21630; (add-text-properties
21631; (or (match-end 1) (match-end 0)) (match-end 0)
21632; (list 'face (org-get-todo-face (match-string 2 x)))
21633; x))
21634 (when (and re 22566 (when (and re
21635 (equal (string-match (concat "\\(\\.*\\)" re "\\( +\\)") 22567 (equal (string-match (concat "\\(\\.*\\)" re "\\( +\\)")
21636 x (or pl 0)) pl)) 22568 x (or pl 0)) pl))
@@ -21793,7 +22725,7 @@ If ERROR is non-nil, throw an error, otherwise just return nil."
21793 (let ((buf (current-buffer))) 22725 (let ((buf (current-buffer)))
21794 (if (not (one-window-p)) (delete-window)) 22726 (if (not (one-window-p)) (delete-window))
21795 (kill-buffer buf) 22727 (kill-buffer buf)
21796 (org-agenda-maybe-reset-markers 'force) 22728 (org-agenda-reset-markers)
21797 (org-columns-remove-overlays)) 22729 (org-columns-remove-overlays))
21798 ;; Maybe restore the pre-agenda window configuration. 22730 ;; Maybe restore the pre-agenda window configuration.
21799 (and org-agenda-restore-windows-after-quit 22731 (and org-agenda-restore-windows-after-quit
@@ -21840,6 +22772,46 @@ When this is the global TODO list, a prefix argument will be interpreted."
21840 (goto-line line) 22772 (goto-line line)
21841 (recenter window-line))) 22773 (recenter window-line)))
21842 22774
22775(defun org-agenda-manipulate-query-add ()
22776 "Manipulate the query by adding a search term with positive selection.
22777Positive selection means, the term must be matched for selection of an entry."
22778 (interactive)
22779 (org-agenda-manipulate-query ?\[))
22780(defun org-agenda-manipulate-query-subtract ()
22781 "Manipulate the query by adding a search term with negative selection.
22782Negative selection means, term must not be matched for selection of an entry."
22783 (interactive)
22784 (org-agenda-manipulate-query ?\]))
22785(defun org-agenda-manipulate-query-add-re ()
22786 "Manipulate the query by adding a search regexp with positive selection.
22787Positive selection means, the regexp must match for selection of an entry."
22788 (interactive)
22789 (org-agenda-manipulate-query ?\{))
22790(defun org-agenda-manipulate-query-subtract-re ()
22791 "Manipulate the query by adding a search regexp with negative selection.
22792Negative selection means, regexp must not match for selection of an entry."
22793 (interactive)
22794 (org-agenda-manipulate-query ?\}))
22795(defun org-agenda-manipulate-query (char)
22796 (cond
22797 ((eq org-agenda-type 'search)
22798 (org-add-to-string
22799 'org-agenda-query-string
22800 (cdr (assoc char '((?\[ . " +") (?\] . " -")
22801 (?\{ . " +{}") (?\} . " -{}")))))
22802 (setq org-agenda-redo-command
22803 (list 'org-search-view
22804 (+ (length org-agenda-query-string)
22805 (if (member char '(?\{ ?\})) 0 1))
22806 org-agenda-query-string))
22807 (set-register org-agenda-query-register org-agenda-query-string)
22808 (org-agenda-redo))
22809 (t (error "Canot manipulate query for %s-type agenda buffers"
22810 org-agenda-type))))
22811
22812(defun org-add-to-string (var string)
22813 (set var (concat (symbol-value var) string)))
22814
21843(defun org-agenda-goto-date (date) 22815(defun org-agenda-goto-date (date)
21844 "Jump to DATE in agenda." 22816 "Jump to DATE in agenda."
21845 (interactive (list (org-read-date))) 22817 (interactive (list (org-read-date)))
@@ -22108,6 +23080,7 @@ and by additional input from the age of a schedules or deadline entry."
22108 (save-excursion 23080 (save-excursion
22109 (and (outline-next-heading) 23081 (and (outline-next-heading)
22110 (org-flag-heading nil)))) ; show the next heading 23082 (org-flag-heading nil)))) ; show the next heading
23083 (recenter (/ (window-height) 2))
22111 (run-hooks 'org-agenda-after-show-hook) 23084 (run-hooks 'org-agenda-after-show-hook)
22112 (and highlight (org-highlight (point-at-bol) (point-at-eol))))) 23085 (and highlight (org-highlight (point-at-bol) (point-at-eol)))))
22113 23086
@@ -22378,8 +23351,8 @@ the new TODO state."
22378 (if line (point-at-eol) nil) t) 23351 (if line (point-at-eol) nil) t)
22379 (add-text-properties 23352 (add-text-properties
22380 (match-beginning 2) (match-end 2) 23353 (match-beginning 2) (match-end 2)
22381 (list 'face (list 'org-tag (get-text-property 23354 (list 'face (delq nil (list 'org-tag (get-text-property
22382 (match-beginning 2) 'face)))) 23355 (match-beginning 2) 'face)))))
22383 (setq l (- (match-end 2) (match-beginning 2)) 23356 (setq l (- (match-end 2) (match-beginning 2))
22384 c (if (< org-agenda-tags-column 0) 23357 c (if (< org-agenda-tags-column 0)
22385 (- (abs org-agenda-tags-column) l) 23358 (- (abs org-agenda-tags-column) l)
@@ -22439,16 +23412,17 @@ the tags of the current headline come last."
22439 (widen) 23412 (widen)
22440 (goto-char (or pos (point))) 23413 (goto-char (or pos (point)))
22441 (save-match-data 23414 (save-match-data
22442 (org-back-to-heading t)
22443 (condition-case nil 23415 (condition-case nil
22444 (while (not (equal lastpos (point))) 23416 (progn
22445 (setq lastpos (point)) 23417 (org-back-to-heading t)
22446 (if (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$")) 23418 (while (not (equal lastpos (point)))
22447 (setq tags (append (org-split-string 23419 (setq lastpos (point))
22448 (org-match-string-no-properties 1) ":") 23420 (if (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$"))
22449 tags))) 23421 (setq tags (append (org-split-string
22450 (or org-use-tag-inheritance (error "")) 23422 (org-match-string-no-properties 1) ":")
22451 (org-up-heading-all 1)) 23423 tags)))
23424 (or org-use-tag-inheritance (error ""))
23425 (org-up-heading-all 1)))
22452 (error nil)))) 23426 (error nil))))
22453 tags))) 23427 tags)))
22454 23428
@@ -22583,10 +23557,13 @@ be used to request time specification in the time stamp."
22583 (org-agenda-check-no-diary) 23557 (org-agenda-check-no-diary)
22584 (let* ((marker (or (get-text-property (point) 'org-marker) 23558 (let* ((marker (or (get-text-property (point) 'org-marker)
22585 (org-agenda-error))) 23559 (org-agenda-error)))
23560 (type (marker-insertion-type marker))
22586 (buffer (marker-buffer marker)) 23561 (buffer (marker-buffer marker))
22587 (pos (marker-position marker)) 23562 (pos (marker-position marker))
22588 (org-insert-labeled-timestamps-at-point nil) 23563 (org-insert-labeled-timestamps-at-point nil)
22589 ts) 23564 ts)
23565 (when type (message "%s" type) (sit-for 3))
23566 (set-marker-insertion-type marker t)
22590 (org-with-remote-undo buffer 23567 (org-with-remote-undo buffer
22591 (with-current-buffer buffer 23568 (with-current-buffer buffer
22592 (widen) 23569 (widen)
@@ -23634,6 +24611,19 @@ translations. There is currently no way for users to extend this.")
23634 (let ((org-inhibit-startup t)) (org-mode)) 24611 (let ((org-inhibit-startup t)) (org-mode))
23635 (untabify (point-min) (point-max)) 24612 (untabify (point-min) (point-max))
23636 24613
24614 ;; Get rid of drawers
24615 (unless (eq t exp-drawers)
24616 (goto-char (point-min))
24617 (let ((re (concat "^[ \t]*:\\("
24618 (mapconcat
24619 'identity
24620 (org-delete-all exp-drawers
24621 (copy-sequence drawers))
24622 "\\|")
24623 "\\):[ \t]*\n\\([^@]*?\n\\)?[ \t]*:END:[ \t]*\n")))
24624 (while (re-search-forward re nil t)
24625 (replace-match ""))))
24626
23637 ;; Get the correct stuff before the first headline 24627 ;; Get the correct stuff before the first headline
23638 (when (plist-get parameters :skip-before-1st-heading) 24628 (when (plist-get parameters :skip-before-1st-heading)
23639 (goto-char (point-min)) 24629 (goto-char (point-min))
@@ -23657,19 +24647,6 @@ translations. There is currently no way for users to extend this.")
23657 b (org-end-of-subtree t)) 24647 b (org-end-of-subtree t))
23658 (if (> b a) (delete-region a b))))) 24648 (if (> b a) (delete-region a b)))))
23659 24649
23660 ;; Get rid of drawers
23661 (unless (eq t exp-drawers)
23662 (goto-char (point-min))
23663 (let ((re (concat "^[ \t]*:\\("
23664 (mapconcat
23665 'identity
23666 (org-delete-all exp-drawers
23667 (copy-sequence drawers))
23668 "\\|")
23669 "\\):[ \t]*\n\\([^@]*?\n\\)?[ \t]*:END:[ \t]*\n")))
23670 (while (re-search-forward re nil t)
23671 (replace-match ""))))
23672
23673 ;; Find targets in comments and move them out of comments, 24650 ;; Find targets in comments and move them out of comments,
23674 ;; but mark them as targets that should be invisible 24651 ;; but mark them as targets that should be invisible
23675 (goto-char (point-min)) 24652 (goto-char (point-min))
@@ -24395,11 +25372,9 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
24395 (if org-odd-levels-only "odd" "oddeven") 25372 (if org-odd-levels-only "odd" "oddeven")
24396 (if org-hide-leading-stars "hidestars" "showstars") 25373 (if org-hide-leading-stars "hidestars" "showstars")
24397 (if org-startup-align-all-tables "align" "noalign") 25374 (if org-startup-align-all-tables "align" "noalign")
24398 (cond ((eq t org-log-done) "logdone") 25375 (cond ((eq org-log-done t) "logdone")
24399 ((not org-log-done) "nologging") 25376 ((equal org-log-done 'note) "lognotedone")
24400 ((listp org-log-done) 25377 ((not org-log-done) "nologdone"))
24401 (mapconcat (lambda (x) (concat "lognote" (symbol-name x)))
24402 org-log-done " ")))
24403 (or (mapconcat (lambda (x) 25378 (or (mapconcat (lambda (x)
24404 (cond 25379 (cond
24405 ((equal '(:startgroup) x) "{") 25380 ((equal '(:startgroup) x) "{")
@@ -24544,7 +25519,7 @@ in a window. A non-interactive call will only retunr the buffer."
24544 25519
24545(defvar html-table-tag nil) ; dynamically scoped into this. 25520(defvar html-table-tag nil) ; dynamically scoped into this.
24546(defun org-export-as-html (arg &optional hidden ext-plist 25521(defun org-export-as-html (arg &optional hidden ext-plist
24547 to-buffer body-only) 25522 to-buffer body-only pub-dir)
24548 "Export the outline as a pretty HTML file. 25523 "Export the outline as a pretty HTML file.
24549If there is an active region, export only the region. The prefix 25524If there is an active region, export only the region. The prefix
24550ARG specifies how many levels of the outline should become 25525ARG specifies how many levels of the outline should become
@@ -24553,11 +25528,12 @@ lists. When HIDDEN is non-nil, don't display the HTML buffer.
24553EXT-PLIST is a property list with external parameters overriding 25528EXT-PLIST is a property list with external parameters overriding
24554org-mode's default settings, but still inferior to file-local 25529org-mode's default settings, but still inferior to file-local
24555settings. When TO-BUFFER is non-nil, create a buffer with that 25530settings. When TO-BUFFER is non-nil, create a buffer with that
24556name and export to that buffer. If TO-BUFFER is the symbol `string', 25531name and export to that buffer. If TO-BUFFER is the symbol
24557don't leave any buffer behind but just return the resulting HTML as 25532`string', don't leave any buffer behind but just return the
24558a string. When BODY-ONLY is set, don't produce the file header and footer, 25533resulting HTML as a string. When BODY-ONLY is set, don't produce
24559simply return the content of <body>...</body>, without even 25534the file header and footer, simply return the content of
24560the body tags themselves." 25535<body>...</body>, without even the body tags themselves. When
25536PUB-DIR is set, use this as the publishing directory."
24561 (interactive "P") 25537 (interactive "P")
24562 25538
24563 ;; Make sure we have a file name when we need it. 25539 ;; Make sure we have a file name when we need it.
@@ -24579,6 +25555,7 @@ the body tags themselves."
24579 (org-infile-export-plist))) 25555 (org-infile-export-plist)))
24580 25556
24581 (style (plist-get opt-plist :style)) 25557 (style (plist-get opt-plist :style))
25558 (html-extension (plist-get opt-plist :html-extension))
24582 (link-validate (plist-get opt-plist :link-validation-function)) 25559 (link-validate (plist-get opt-plist :link-validation-function))
24583 valid thetoc have-headings first-heading-pos 25560 valid thetoc have-headings first-heading-pos
24584 (odd org-odd-levels-only) 25561 (odd org-odd-levels-only)
@@ -24591,7 +25568,8 @@ the body tags themselves."
24591 (>= (org-end-of-subtree t t) (region-end)))))) 25568 (>= (org-end-of-subtree t t) (region-end))))))
24592 ;; The following two are dynamically scoped into other 25569 ;; The following two are dynamically scoped into other
24593 ;; routines below. 25570 ;; routines below.
24594 (org-current-export-dir (org-export-directory :html opt-plist)) 25571 (org-current-export-dir
25572 (or pub-dir (org-export-directory :html opt-plist)))
24595 (org-current-export-file buffer-file-name) 25573 (org-current-export-file buffer-file-name)
24596 (level 0) (line "") (origline "") txt todo 25574 (level 0) (line "") (origline "") txt todo
24597 (umax nil) 25575 (umax nil)
@@ -24604,9 +25582,9 @@ the body tags themselves."
24604 (org-entry-get (region-beginning) 25582 (org-entry-get (region-beginning)
24605 "EXPORT_FILE_NAME" t)) 25583 "EXPORT_FILE_NAME" t))
24606 (file-name-nondirectory buffer-file-name))) 25584 (file-name-nondirectory buffer-file-name)))
24607 "." org-export-html-extension) 25585 "." html-extension)
24608 (file-name-as-directory 25586 (file-name-as-directory
24609 (org-export-directory :html opt-plist))))) 25587 (or pub-dir (org-export-directory :html opt-plist))))))
24610 (current-dir (if buffer-file-name 25588 (current-dir (if buffer-file-name
24611 (file-name-directory buffer-file-name) 25589 (file-name-directory buffer-file-name)
24612 default-directory)) 25590 default-directory))
@@ -24960,7 +25938,7 @@ lang=\"%s\" xml:lang=\"%s\">
24960 (string-match "\\.org$" thefile)) 25938 (string-match "\\.org$" thefile))
24961 (setq thefile (concat (substring thefile 0 25939 (setq thefile (concat (substring thefile 0
24962 (match-beginning 0)) 25940 (match-beginning 0))
24963 "." org-export-html-extension)) 25941 "." html-extension))
24964 (if (and search 25942 (if (and search
24965 ;; make sure this is can be used as target search 25943 ;; make sure this is can be used as target search
24966 (not (string-match "^[0-9]*$" search)) 25944 (not (string-match "^[0-9]*$" search))
@@ -25062,7 +26040,7 @@ lang=\"%s\" xml:lang=\"%s\">
25062 (cond 26040 (cond
25063 ((eq llt t) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+[.)]\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)") 26041 ((eq llt t) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+[.)]\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
25064 ((= llt ?.) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+\\.\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)") 26042 ((= llt ?.) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+\\.\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
25065 ((= llt ?\)) "^\\( \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)") 26043 ((= llt ?\)) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
25066 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'"))) 26044 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
25067 line) 26045 line)
25068 (setq ind (org-get-string-indentation line) 26046 (setq ind (org-get-string-indentation line)
@@ -25199,6 +26177,9 @@ lang=\"%s\" xml:lang=\"%s\">
25199 (goto-char (point-min)) 26177 (goto-char (point-min))
25200 (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t) 26178 (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t)
25201 (replace-match "")) 26179 (replace-match ""))
26180 (goto-char (point-min))
26181 (while (re-search-forward "</ul>\\s-*<ul>\n?" nil t)
26182 (replace-match ""))
25202 ;; Convert whitespace place holders 26183 ;; Convert whitespace place holders
25203 (goto-char (point-min)) 26184 (goto-char (point-min))
25204 (let (beg end n) 26185 (let (beg end n)
@@ -25209,7 +26190,6 @@ lang=\"%s\" xml:lang=\"%s\">
25209 (delete-region beg end) 26190 (delete-region beg end)
25210 (insert (format "<span style=\"visibility:hidden;\">%s</span>" 26191 (insert (format "<span style=\"visibility:hidden;\">%s</span>"
25211 (make-string n ?x))))) 26192 (make-string n ?x)))))
25212
25213 (or to-buffer (save-buffer)) 26193 (or to-buffer (save-buffer))
25214 (goto-char (point-min)) 26194 (goto-char (point-min))
25215 (message "Exporting... done") 26195 (message "Exporting... done")
@@ -25771,7 +26751,6 @@ file and store it under the name `org-combined-agenda-icalendar-file'."
25771 :ical (list :publishing-directory 26751 :ical (list :publishing-directory
25772 org-export-publishing-directory))) 26752 org-export-publishing-directory)))
25773 file ical-file ical-buffer category started org-agenda-new-buffers) 26753 file ical-file ical-buffer category started org-agenda-new-buffers)
25774
25775 (and (get-buffer "*ical-tmp*") (kill-buffer "*ical-tmp*")) 26754 (and (get-buffer "*ical-tmp*") (kill-buffer "*ical-tmp*"))
25776 (when combine 26755 (when combine
25777 (setq ical-file 26756 (setq ical-file
@@ -25831,6 +26810,11 @@ When COMBINE is non nil, add the category to each line."
25831 (while (re-search-forward re1 nil t) 26810 (while (re-search-forward re1 nil t)
25832 (catch :skip 26811 (catch :skip
25833 (org-agenda-skip) 26812 (org-agenda-skip)
26813 (when (boundp 'org-icalendar-verify-function)
26814 (unless (funcall org-icalendar-verify-function)
26815 (outline-next-heading)
26816 (backward-char 1)
26817 (throw :skip nil)))
25834 (setq pos (match-beginning 0) 26818 (setq pos (match-beginning 0)
25835 ts (match-string 0) 26819 ts (match-string 0)
25836 inc t 26820 inc t
@@ -25921,6 +26905,11 @@ END:VEVENT\n"
25921 (while (re-search-forward org-todo-line-regexp nil t) 26905 (while (re-search-forward org-todo-line-regexp nil t)
25922 (catch :skip 26906 (catch :skip
25923 (org-agenda-skip) 26907 (org-agenda-skip)
26908 (when (boundp 'org-icalendar-verify-function)
26909 (unless (funcall org-icalendar-verify-function)
26910 (outline-next-heading)
26911 (backward-char 1)
26912 (throw :skip nil)))
25924 (setq state (match-string 2)) 26913 (setq state (match-string 2))
25925 (setq status (if (member state org-done-keywords) 26914 (setq status (if (member state org-done-keywords)
25926 "COMPLETED" "NEEDS-ACTION")) 26915 "COMPLETED" "NEEDS-ACTION"))
@@ -26237,6 +27226,7 @@ The XOXO buffer is named *xoxo-<source buffer name>*"
26237(org-defkey org-mode-map "\C-c\C-x<" 'org-agenda-set-restriction-lock) 27226(org-defkey org-mode-map "\C-c\C-x<" 'org-agenda-set-restriction-lock)
26238(org-defkey org-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock) 27227(org-defkey org-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
26239(org-defkey org-mode-map "\C-c-" 'org-ctrl-c-minus) 27228(org-defkey org-mode-map "\C-c-" 'org-ctrl-c-minus)
27229(org-defkey org-mode-map "\C-c*" 'org-ctrl-c-star)
26240(org-defkey org-mode-map "\C-c^" 'org-sort) 27230(org-defkey org-mode-map "\C-c^" 'org-sort)
26241(org-defkey org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) 27231(org-defkey org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c)
26242(org-defkey org-mode-map "\C-c\C-k" 'org-kill-note-or-show-branches) 27232(org-defkey org-mode-map "\C-c\C-k" 'org-kill-note-or-show-branches)
@@ -26250,7 +27240,6 @@ The XOXO buffer is named *xoxo-<source buffer name>*"
26250(org-defkey org-mode-map "\C-c'" 'org-table-edit-formulas) 27240(org-defkey org-mode-map "\C-c'" 'org-table-edit-formulas)
26251(org-defkey org-mode-map "\C-c`" 'org-table-edit-field) 27241(org-defkey org-mode-map "\C-c`" 'org-table-edit-field)
26252(org-defkey org-mode-map "\C-c|" 'org-table-create-or-convert-from-region) 27242(org-defkey org-mode-map "\C-c|" 'org-table-create-or-convert-from-region)
26253(org-defkey org-mode-map "\C-c*" 'org-table-recalculate)
26254(org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks) 27243(org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks)
26255(org-defkey org-mode-map "\C-c~" 'org-table-create-with-table.el) 27244(org-defkey org-mode-map "\C-c~" 'org-table-create-with-table.el)
26256(org-defkey org-mode-map "\C-c\C-q" 'org-table-wrap-region) 27245(org-defkey org-mode-map "\C-c\C-q" 'org-table-wrap-region)
@@ -26718,22 +27707,58 @@ See the individual commands for more information."
26718 (interactive) 27707 (interactive)
26719 (cond 27708 (cond
26720 ((bobp) (if indent (newline-and-indent) (newline))) 27709 ((bobp) (if indent (newline-and-indent) (newline)))
27710 ((and (org-at-heading-p)
27711 (looking-at
27712 (org-re "\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$")))
27713 (org-show-entry)
27714 (end-of-line 1)
27715 (newline))
26721 ((org-at-table-p) 27716 ((org-at-table-p)
26722 (org-table-justify-field-maybe) 27717 (org-table-justify-field-maybe)
26723 (call-interactively 'org-table-next-row)) 27718 (call-interactively 'org-table-next-row))
26724 (t (if indent (newline-and-indent) (newline))))) 27719 (t (if indent (newline-and-indent) (newline)))))
26725 27720
26726(defun org-return-indent () 27721(defun org-return-indent ()
26727 (interactive)
26728 "Goto next table row or insert a newline and indent. 27722 "Goto next table row or insert a newline and indent.
26729Calls `org-table-next-row' or `newline-and-indent', depending on 27723Calls `org-table-next-row' or `newline-and-indent', depending on
26730context. See the individual commands for more information." 27724context. See the individual commands for more information."
27725 (interactive)
26731 (org-return t)) 27726 (org-return t))
26732 27727
27728(defun org-ctrl-c-star ()
27729 "Compute table, or change heading status of lines.
27730Calls `org-table-recalculate' or `org-toggle-region-headlines',
27731depending on context. This will also turn a plain list item or a normal
27732line into a subheading."
27733 (interactive)
27734 (cond
27735 ((org-at-table-p)
27736 (call-interactively 'org-table-recalculate))
27737 ((org-region-active-p)
27738 ;; Convert all lines in region to list items
27739 (call-interactively 'org-toggle-region-headings))
27740 ((org-on-heading-p)
27741 (org-toggle-region-headings (point-at-bol)
27742 (min (1+ (point-at-eol)) (point-max))))
27743 ((org-at-item-p)
27744 ;; Convert to heading
27745 (let ((level (save-match-data
27746 (save-excursion
27747 (condition-case nil
27748 (progn
27749 (org-back-to-heading t)
27750 (funcall outline-level))
27751 (error 0))))))
27752 (replace-match
27753 (concat (make-string (org-get-valid-level level 1) ?*) " ") t t)))
27754 (t (org-toggle-region-headings (point-at-bol)
27755 (min (1+ (point-at-eol)) (point-max))))))
27756
26733(defun org-ctrl-c-minus () 27757(defun org-ctrl-c-minus ()
26734 "Insert separator line in table or modify bullet type in list. 27758 "Insert separator line in table or modify bullet status of line.
26735Calls `org-table-insert-hline' or `org-cycle-list-bullet', 27759Also turns a plain line or a region of lines into list items.
26736depending on context." 27760Calls `org-table-insert-hline', `org-toggle-region-items', or
27761`org-cycle-list-bullet', depending on context."
26737 (interactive) 27762 (interactive)
26738 (cond 27763 (cond
26739 ((org-at-table-p) 27764 ((org-at-table-p)
@@ -26743,11 +27768,70 @@ depending on context."
26743 (save-excursion 27768 (save-excursion
26744 (beginning-of-line 1) 27769 (beginning-of-line 1)
26745 (if (looking-at "\\*+ ") 27770 (if (looking-at "\\*+ ")
26746 (replace-match (concat (make-string (- (match-end 0) (point)) ?\ ) "- "))))) 27771 (replace-match (concat (make-string (- (match-end 0) (point) 1) ?\ ) "- ")))))
27772 ((org-region-active-p)
27773 ;; Convert all lines in region to list items
27774 (call-interactively 'org-toggle-region-items))
26747 ((org-in-item-p) 27775 ((org-in-item-p)
26748 (call-interactively 'org-cycle-list-bullet)) 27776 (call-interactively 'org-cycle-list-bullet))
26749 (t (error "`C-c -' does have no function here.")))) 27777 (t (org-toggle-region-items (point-at-bol)
27778 (min (1+ (point-at-eol)) (point-max))))))
26750 27779
27780(defun org-toggle-region-items (beg end)
27781 "Convert all lines in region to list items.
27782If the first line is already an item, convert all list items in the region
27783to normal lines."
27784 (interactive "r")
27785 (let (l2 l)
27786 (save-excursion
27787 (goto-char end)
27788 (setq l2 (org-current-line))
27789 (goto-char beg)
27790 (beginning-of-line 1)
27791 (setq l (1- (org-current-line)))
27792 (if (org-at-item-p)
27793 ;; We already have items, de-itemize
27794 (while (< (setq l (1+ l)) l2)
27795 (when (org-at-item-p)
27796 (goto-char (match-beginning 2))
27797 (delete-region (match-beginning 2) (match-end 2))
27798 (and (looking-at "[ \t]+") (replace-match "")))
27799 (beginning-of-line 2))
27800 (while (< (setq l (1+ l)) l2)
27801 (unless (org-at-item-p)
27802 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
27803 (replace-match "\\1- \\2")))
27804 (beginning-of-line 2))))))
27805
27806(defun org-toggle-region-headings (beg end)
27807 "Convert all lines in region to list items.
27808If the first line is already an item, convert all list items in the region
27809to normal lines."
27810 (interactive "r")
27811 (let (l2 l)
27812 (save-excursion
27813 (goto-char end)
27814 (setq l2 (org-current-line))
27815 (goto-char beg)
27816 (beginning-of-line 1)
27817 (setq l (1- (org-current-line)))
27818 (if (org-on-heading-p)
27819 ;; We already have headlines, de-star them
27820 (while (< (setq l (1+ l)) l2)
27821 (when (org-on-heading-p t)
27822 (and (looking-at outline-regexp) (replace-match "")))
27823 (beginning-of-line 2))
27824 (let* ((stars (save-excursion
27825 (re-search-backward org-complex-heading-regexp nil t)
27826 (or (match-string 1) "*")))
27827 (add-stars (if org-odd-levels-only "**" "*"))
27828 (rpl (concat stars add-stars " \\2")))
27829 (while (< (setq l (1+ l)) l2)
27830 (unless (org-on-heading-p)
27831 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
27832 (replace-match rpl)))
27833 (beginning-of-line 2)))))))
27834
26751(defun org-meta-return (&optional arg) 27835(defun org-meta-return (&optional arg)
26752 "Insert a new heading or wrap a region in a table. 27836 "Insert a new heading or wrap a region in a table.
26753Calls `org-insert-heading' or `org-table-wrap-region', depending on context. 27837Calls `org-insert-heading' or `org-table-wrap-region', depending on context.
@@ -27169,7 +28253,7 @@ really on, so that the block visually is on the match."
27169 (interactive "sOrg-files matching: \np") 28253 (interactive "sOrg-files matching: \np")
27170 (let* ((files (org-agenda-files)) 28254 (let* ((files (org-agenda-files))
27171 (tnames (mapcar 'file-truename files)) 28255 (tnames (mapcar 'file-truename files))
27172 (extra org-agenda-multi-occur-extra-files) 28256 (extra org-agenda-text-search-extra-files)
27173 f) 28257 f)
27174 (while (setq f (pop extra)) 28258 (while (setq f (pop extra))
27175 (unless (member (file-truename f) tnames) 28259 (unless (member (file-truename f) tnames)
@@ -27179,6 +28263,28 @@ really on, so that the block visually is on the match."
27179 (mapcar (lambda (x) (or (get-file-buffer x) (find-file-noselect x))) files) 28263 (mapcar (lambda (x) (or (get-file-buffer x) (find-file-noselect x))) files)
27180 regexp))) 28264 regexp)))
27181 28265
28266(if (boundp 'occur-mode-find-occurrence-hook)
28267 ;; Emacs 23
28268 (add-hook 'occur-mode-find-occurrence-hook
28269 (lambda ()
28270 (when (org-mode-p)
28271 (org-reveal))))
28272 ;; Emacs 22
28273 (defadvice occur-mode-goto-occurrence
28274 (after org-occur-reveal activate)
28275 (and (org-mode-p) (org-reveal)))
28276 (defadvice occur-mode-goto-occurrence-other-window
28277 (after org-occur-reveal activate)
28278 (and (org-mode-p) (org-reveal)))
28279 (defadvice occur-mode-display-occurrence
28280 (after org-occur-reveal activate)
28281 (when (org-mode-p)
28282 (let ((pos (occur-mode-find-occurrence)))
28283 (with-current-buffer (marker-buffer pos)
28284 (save-excursion
28285 (goto-char pos)
28286 (org-reveal)))))))
28287
27182(defun org-uniquify (list) 28288(defun org-uniquify (list)
27183 "Remove duplicate elements from LIST." 28289 "Remove duplicate elements from LIST."
27184 (let (res) 28290 (let (res)
@@ -27402,7 +28508,12 @@ not an indirect buffer"
27402 ;; `adaptive-fill-regexp' never matches. Then install our own matcher. 28508 ;; `adaptive-fill-regexp' never matches. Then install our own matcher.
27403 (org-set-local 'adaptive-fill-regexp "\000") 28509 (org-set-local 'adaptive-fill-regexp "\000")
27404 (org-set-local 'adaptive-fill-function 28510 (org-set-local 'adaptive-fill-function
27405 'org-adaptive-fill-function)) 28511 'org-adaptive-fill-function)
28512 (org-set-local
28513 'align-mode-rules-list
28514 '((org-in-buffer-settings
28515 (regexp . "^#\\+[A-Z_]+:\\(\\s-*\\)\\S-+")
28516 (modes . '(org-mode))))))
27406 28517
27407(defun org-fill-paragraph (&optional justify) 28518(defun org-fill-paragraph (&optional justify)
27408 "Re-align a table, pass through to fill-paragraph if no table." 28519 "Re-align a table, pass through to fill-paragraph if no table."
@@ -27433,6 +28544,7 @@ work correctly."
27433 28544
27434;;;; Functions extending outline functionality 28545;;;; Functions extending outline functionality
27435 28546
28547
27436(defun org-beginning-of-line (&optional arg) 28548(defun org-beginning-of-line (&optional arg)
27437 "Go to the beginning of the current line. If that is invisible, continue 28549 "Go to the beginning of the current line. If that is invisible, continue
27438to a visible line beginning. This makes the function of C-a more intuitive. 28550to a visible line beginning. This makes the function of C-a more intuitive.
@@ -27497,6 +28609,21 @@ beyond the end of the headline."
27497(define-key org-mode-map "\C-a" 'org-beginning-of-line) 28609(define-key org-mode-map "\C-a" 'org-beginning-of-line)
27498(define-key org-mode-map "\C-e" 'org-end-of-line) 28610(define-key org-mode-map "\C-e" 'org-end-of-line)
27499 28611
28612(defun org-kill-line (&optional arg)
28613 "Kill line, to tags or end of line."
28614 (interactive "P")
28615 (cond
28616 ((or (not org-special-ctrl-k)
28617 (bolp)
28618 (not (org-on-heading-p)))
28619 (call-interactively 'kill-line))
28620 ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$"))
28621 (kill-region (point) (match-beginning 1))
28622 (org-set-tags nil t))
28623 (t (kill-region (point) (point-at-eol)))))
28624
28625(define-key org-mode-map "\C-k" 'org-kill-line)
28626
27500(defun org-invisible-p () 28627(defun org-invisible-p ()
27501 "Check if point is at a character currently not visible." 28628 "Check if point is at a character currently not visible."
27502 ;; Early versions of noutline don't have `outline-invisible-p'. 28629 ;; Early versions of noutline don't have `outline-invisible-p'.
@@ -27810,13 +28937,6 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
27810 (org-invisible-p))) 28937 (org-invisible-p)))
27811 (org-show-context 'bookmark-jump))) 28938 (org-show-context 'bookmark-jump)))
27812 28939
27813;; Fix a bug in htmlize where there are text properties (face nil)
27814(eval-after-load "htmlize"
27815 '(progn
27816 (defadvice htmlize-faces-in-buffer (after org-no-nil-faces activate)
27817 "Make sure there are no nil faces"
27818 (setq ad-return-value (delq nil ad-return-value)))))
27819
27820;; Make session.el ignore our circular variable 28940;; Make session.el ignore our circular variable
27821(eval-after-load "session" 28941(eval-after-load "session"
27822 '(add-to-list 'session-globals-exclude 'org-mark-ring)) 28942 '(add-to-list 'session-globals-exclude 'org-mark-ring))
@@ -27844,6 +28964,7 @@ Still experimental, may disappear in the future."
27844 ;; make tree, check each match with the callback 28964 ;; make tree, check each match with the callback
27845 (org-occur "CLOSED: +\\[\\(.*?\\)\\]" nil callback))) 28965 (org-occur "CLOSED: +\\[\\(.*?\\)\\]" nil callback)))
27846 28966
28967
27847;;;; Finish up 28968;;;; Finish up
27848 28969
27849(provide 'org) 28970(provide 'org)