diff options
Diffstat (limited to 'lisp/org/org.el')
-rw-r--r-- | lisp/org/org.el | 845 |
1 files changed, 632 insertions, 213 deletions
diff --git a/lisp/org/org.el b/lisp/org/org.el index d3db0094aab..7b2e95b0976 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik <carsten at orgmode dot org> ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -95,35 +95,36 @@ ;;; Version -(defconst org-version "6.31a" +(defconst org-version "6.33" "The version number of the file org.el.") (defun org-version (&optional here) "Show the org-mode version in the echo area. With prefix arg HERE, insert it at point." (interactive "P") - (let* ((version org-version) + (let* ((origin default-directory) + (version org-version) (git-version) (dir (concat (file-name-directory (locate-library "org")) "../" ))) - (if (and (file-exists-p (expand-file-name ".git" dir)) - (executable-find "git")) - (let ((pwd (substring (pwd) 10))) - (cd dir) - (if (eql 0 (shell-command "git describe --abbrev=4 HEAD")) + (when (and (file-exists-p (expand-file-name ".git" dir)) + (executable-find "git")) + (unwind-protect + (progn + (cd dir) + (when (eql 0 (shell-command "git describe --abbrev=4 HEAD")) (with-current-buffer "*Shell Command Output*" (goto-char (point-min)) - (re-search-forward "[^\n]+") - (setq git-version (match-string 0)) - (subst-char-in-string ?- ?. git-version t) - (shell-command "git diff-index --name-only HEAD --") - (unless (eql 1 (point-max)) - (setq git-version (concat git-version ".dirty"))) - (setq version (concat version " (" git-version ")"))) - (cd pwd)))) + (setq git-version (buffer-substring (point) (point-at-eol)))) + (subst-char-in-string ?- ?. git-version t) + (when (string-match "\\S-" + (shell-command-to-string + "git diff-index --name-only HEAD --")) + (setq git-version (concat git-version ".dirty"))) + (setq version (concat version " (" git-version ")")))) + (cd origin))) (setq version (format "Org-mode version %s" version)) (if here (insert version)) - (message version) - version)) + (message version))) ;;; Compatibility constants @@ -136,6 +137,11 @@ With prefix arg HERE, insert it at point." :group 'hypermedia :group 'calendar) +(defcustom org-mode-hook nil + "Mode hook for Org-mode, run after the mode was turned on." + :group 'org + :type 'hook) + (defcustom org-load-hook nil "Hook that is run after org.el has been loaded." :group 'org @@ -187,6 +193,7 @@ to add the symbol `xyz', and the package must have a call to (const :tag " id: Global IDs for identifying entries" org-id) (const :tag " info: Links to Info nodes" org-info) (const :tag " jsinfo: Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo) + (const :tag " habit: Track your consistency with habits" org-habit) (const :tag " inlinetask: Tasks independent of outline hierarchy" org-inlinetask) (const :tag " irc: Links to IRC/ERC chat sessions" org-irc) (const :tag " mac-message: Links to messages in Apple Mail" org-mac-message) @@ -196,40 +203,40 @@ to add the symbol `xyz', and the package must have a call to (const :tag " rmail: Links to RMAIL folders/messages" org-rmail) (const :tag " vm: Links to VM folders/messages" org-vm) (const :tag " wl: Links to Wanderlust folders/messages" org-wl) - (const :tag " w3m: Special cut/paste from w3m to Org." org-w3m) + (const :tag " w3m: Special cut/paste from w3m to Org-mode." org-w3m) (const :tag " mouse: Additional mouse support" org-mouse) (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file) - (const :tag "C annotation-helper: Call Remember directly from Browser\n\t\t\t(OBSOLETE, use org-protocol)" org-annotation-helper) - (const :tag "C bookmark: Org links to bookmarks" org-bookmark) - (const :tag "C browser-url: Store link, directly from Browser\n\t\t\t(OBSOLETE, use org-protocol)" org-browser-url) + (const :tag "C bookmark: Org-mode links to bookmarks" org-bookmark) (const :tag "C checklist: Extra functions for checklists in repeated tasks" org-checklist) (const :tag "C choose: Use TODO keywords to mark decisions states" org-choose) (const :tag "C collector: Collect properties into tables" org-collector) (const :tag "C depend: TODO dependencies for Org-mode\n\t\t\t(PARTIALLY OBSOLETE, see built-in dependency support))" org-depend) - (const :tag "C elisp-symbol: Org links to emacs-lisp symbols" org-elisp-symbol) + (const :tag "C elisp-symbol: Org-mode links to emacs-lisp symbols" org-elisp-symbol) (const :tag "C eval: Include command output as text" org-eval) (const :tag "C eval-light: Evaluate inbuffer-code on demand" org-eval-light) - (const :tag "C expiry: Expiry mechanism for Org entries" org-expiry) + (const :tag "C expiry: Expiry mechanism for Org-mode entries" org-expiry) (const :tag "C exp-bibtex: Export citations using BibTeX" org-exp-bibtex) + (const :tag "C git-link: Provide org links to specific file version" org-git-link) (const :tag "C interactive-query: Interactive modification of tags query\n\t\t\t(PARTIALLY OBSOLETE, see secondary filtering)" org-interactive-query) - (const :tag "C invoice Help manage client invoices in OrgMode" org-invoice) + (const :tag "C invoice: Help manage client invoices in Org-mode" org-invoice) - (const :tag "C jira Add a jira:ticket protocol to Org" org-jira) - (const :tag "C mairix: Hook mairix search into Org for different MUAs" org-mairix) + (const :tag "C jira: Add a jira:ticket protocol to Org-mode" org-jira) + (const :tag "C learn: SuperMemo's incremental learning algorithm" org-learn) + (const :tag "C mairix: Hook mairix search into Org-mode for different MUAs" org-mairix) (const :tag "C mac-iCal Imports events from iCal.app to the Emacs diary" org-mac-iCal) (const :tag "C man: Support for links to manpages in Org-mode" org-man) (const :tag "C mtags: Support for muse-like tags" org-mtags) (const :tag "C panel: Simple routines for us with bad memory" org-panel) (const :tag "C R: Computation using the R language" org-R) - (const :tag "C registry: A registry for Org links" org-registry) + (const :tag "C registry: A registry for Org-mode links" org-registry) (const :tag "C org2rem: Convert org appointments into reminders" org2rem) (const :tag "C screen: Visit screen sessions through Org-mode links" org-screen) (const :tag "C special-blocks: Turn blocks into LaTeX envs and HTML divs" org-special-blocks) (const :tag "C sqlinsert: Convert Org-mode tables to SQL insertions" orgtbl-sqlinsert) (const :tag "C toc: Table of contents for Org-mode buffer" org-toc) - (const :tag "C track: Keep up with Org development" org-track) + (const :tag "C track: Keep up with Org-mode development" org-track) (repeat :tag "External packages" :inline t (symbol :tag "Package")))) (defcustom org-support-shift-select nil @@ -473,7 +480,7 @@ An entry can be toggled between QUOTE and normal with :type 'string) (defconst org-repeat-re - "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*\\([.+]?\\+[0-9]+[dwmy]\\)" + "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*?\\([.+]?\\+[0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)" "Regular expression for specifying repeated events. After a match, group 1 contains the repeat expression.") @@ -586,6 +593,28 @@ new-frame Make a new frame each time. Note that in this case (const :tag "Each time a new frame" new-frame) (const :tag "One dedicated frame" dedicated-frame))) +(defcustom org-use-speed-commands nil + "Non-nil means, activate single letter commands at beginning of a headline." + :group 'org-structure + :type 'boolean) + +(defcustom org-speed-commands-user nil + "Alist of additional speed commands. +This list will be checked before `org-speed-commands-default' +when the variable `org-use-speed-commands' is non-nil +and when the cursor is at the beginning of a headline. +The car if each entry is a string with a single letter, which must +be assigned to `self-insert-command' in the global map. +The cdr is either a command to be called interactively, a function +to be called, or a form to be evaluated." + :group 'org-structure + :type '(repeat + (cons + (string "Command letter") + (choice + (function) + (sexp))))) + (defgroup org-cycle nil "Options concerning visibility cycling in Org-mode." :tag "Org Cycle" @@ -650,6 +679,21 @@ of the buffer." :group 'org-cycle :type 'boolean) +(defcustom org-cycle-level-after-item/entry-creation t + "Non-nil means, cycle entry level or item indentation in new empty entries. + +When the cursor is at the end of an empty headline, i.e with only stars +and maybe a TODO keyword, TAB will then switch the entry to become a child, +and then all possible anchestor states, before returning to the original state. +This makes data entry extremely fast: M-RET to create a new headline, +on TAB to make it a child, two or more tabs to make it a (grand-)uncle. + +When the cursor is at the end of an empty plain list item, one TAB will +make it a subitem, two or more tabs will back up to make this an item +higher up in the item hierarchy." + :group 'org-cycle + :type 'boolean) + (defcustom org-cycle-emulate-tab t "Where should `org-cycle' emulate TAB. nil Never @@ -971,7 +1015,7 @@ See also the variable `org-table-auto-blank-field'." (defcustom org-self-insert-cluster-for-undo t "Non-nil means cluster self-insert commands for undo when possible. -If this is set, then, like in the Emacs command loop, 20 consequtive +If this is set, then, like in the Emacs command loop, 20 consecutive characters will be undone together. This is configurable, because there is some impact on typing performance." :group 'org-table @@ -1290,7 +1334,7 @@ changes to the current buffer." When nil, an error will be generated. This variable applies only to external applications because they might choke on non-existing files. If the link is to a file that -will be openend in Emacs, the variable is ignored." +will be opened in Emacs, the variable is ignored." :group 'org-link-follow :type 'boolean) @@ -1388,6 +1432,7 @@ See `org-file-apps'.") (defcustom org-file-apps '( (auto-mode . emacs) + ("\\.mm\\'" . default) ("\\.x?html?\\'" . default) ("\\.pdf\\'" . default) ) @@ -1905,7 +1950,7 @@ Possible values are: nil Don't add anything, just change the keyword time Add a time stamp to the task -note Prompt a closing note and add it with template `org-log-note-headings' +note Prompt for a note and add it with template `org-log-note-headings' This option can also be set with on a per-file-basis with @@ -1920,7 +1965,7 @@ property to one or more of these keywords." :type '(choice (const :tag "No logging" nil) (const :tag "Record CLOSED timestamp" time) - (const :tag "Record CLOSED timestamp with closing note." note))) + (const :tag "Record CLOSED timestamp with note." note))) ;; Normalize old uses of org-log-done. (cond @@ -1928,6 +1973,51 @@ property to one or more of these keywords." ((and (listp org-log-done) (memq 'done org-log-done)) (setq org-log-done 'note))) +(defcustom org-log-reschedule nil + "Information to record when the scheduling date of a tasks is modified. + +Possible values are: + +nil Don't add anything, just change the date +time Add a time stamp to the task +note Prompt for a note and add it with template `org-log-note-headings' + +This option can also be set with on a per-file-basis with + + #+STARTUP: nologreschedule + #+STARTUP: logreschedule + #+STARTUP: lognotereschedule" + :group 'org-todo + :group 'org-progress + :type '(choice + (const :tag "No logging" nil) + (const :tag "Record timestamp" time) + (const :tag "Record timestamp with note." note))) + +(defcustom org-log-redeadline nil + "Information to record when the deadline date of a tasks is modified. + +Possible values are: + +nil Don't add anything, just change the date +time Add a time stamp to the task +note Prompt for a note and add it with template `org-log-note-headings' + +This option can also be set with on a per-file-basis with + + #+STARTUP: nologredeadline + #+STARTUP: logredeadline + #+STARTUP: lognoteredeadline + +You can have local logging settings for a subtree by setting the LOGGING +property to one or more of these keywords." + :group 'org-todo + :group 'org-progress + :type '(choice + (const :tag "No logging" nil) + (const :tag "Record timestamp" time) + (const :tag "Record timestamp with note." note))) + (defcustom org-log-note-clock-out nil "Non-nil means, record a note when clocking out of an item. This can also be configured on a per-file basis by adding one of @@ -1949,6 +2039,8 @@ When nil, only the date will be recorded." '((done . "CLOSING NOTE %t") (state . "State %-12s from %-12S %t") (note . "Note taken on %t") + (reschedule . "Rescheduled from %S on %t") + (redeadline . "New deadline from %S on %t") (clock-out . "")) "Headings for notes added to entries. The value is an alist, with the car being a symbol indicating the note @@ -1967,7 +2059,9 @@ empty string. "Heading when changing todo state (todo sequence only)" state) string) (cons (const :tag "Heading when just taking a note" note) string) - (cons (const :tag "Heading when clocking out" clock-out) string))) + (cons (const :tag "Heading when clocking out" clock-out) string) + (cons (const :tag "Heading when rescheduling" reschedule) string) + (cons (const :tag "Heading when changing deadline" redeadline) string))) (unless (assq 'note org-log-note-headings) (push '(note . "%t") org-log-note-headings)) @@ -2173,6 +2267,18 @@ org-mode generates a time duration." :group 'org-time :type 'string) +(defcustom org-time-clocksum-use-fractional nil + "If non-nil, \\[org-clock-display] uses fractional times. +org-mode generates a time duration." + :group 'org-time + :type 'boolean) + +(defcustom org-time-clocksum-fractional-format "%.2f" + "The format string used when creating CLOCKSUM lines, or when +org-mode generates a time duration." + :group 'org-time + :type 'string) + (defcustom org-deadline-warning-days 14 "No. of days before expiration during which a deadline becomes active. This variable governs the display in sparse trees and in the agenda. @@ -2187,20 +2293,29 @@ Custom commands can set this variable in the options section." (defcustom org-read-date-prefer-future t "Non-nil means, assume future for incomplete date input from user. This affects the following situations: -1. The user gives a day, but no month. +1. The user gives a month but not a year. + For example, if it is april and you enter \"feb 2\", this will be read + as feb 2, *next* year. \"May 5\", however, will be this year. +2. The user gives a day, but no month. For example, if today is the 15th, and you enter \"3\", Org-mode will read this as the third of *next* month. However, if you enter \"17\", it will be considered as *this* month. -2. The user gives a month but not a year. - For example, if it is april and you enter \"feb 2\", this will be read - as feb 2, *next* year. \"May 5\", however, will be this year. -Currently this does not work for ISO week specifications. +If you set this variable to the symbol `time', then also the following +will work: + +3. If the user gives a time, but no day. If the time is before now, + to will be interpreted as tomorrow. -When this option is nil, the current month and year will always be used -as defaults." +Currently none of this works for ISO week specifications. + +When this option is nil, the current day, month and year will always be +used as defaults." :group 'org-time - :type 'boolean) + :type '(choice + (const :tag "Never" nil) + (const :tag "Check month and day" t) + (const :tag "Check month, day, and time" time))) (defcustom org-read-date-display-live t "Non-nil means, display current interpretation of date prompt live. @@ -2272,8 +2387,12 @@ See the manual for details." (choice (cons (string :tag "Tag name") (character :tag "Access char")) - (const :tag "Start radio group" (:startgroup)) - (const :tag "End radio group" (:endgroup)) + (list :tag "Start radio group" + (const :startgroup) + (option (string :tag "Group description"))) + (list :tag "End radio group" + (const :endgroup) + (option (string :tag "Group description"))) (const :tag "New line" (:newline))))) (defcustom org-tag-persistent-alist nil @@ -2300,7 +2419,7 @@ To disable these tags on a per-file basis, insert anywhere in the file: "List of tags that can be inherited by all entries in the file. The tags will be inherited if the variable `org-use-tag-inheritance' says they should be. -This variable is populated from #+TAG lines.") +This variable is populated from #+FILETAGS lines.") (defcustom org-use-fast-tag-selection 'auto "Non-nil means, use fast tag selection scheme. @@ -2640,12 +2759,39 @@ default is the character `k' because we use the same key in the agenda." :group 'org-agenda :type 'sexp) +(defcustom org-calendar-insert-diary-entry-key [?i] + "The key to be installed in `calendar-mode-map' for adding diary entries. +This option is irrelevant until `org-agenda-diary-file' has been configured +to point to an Org-mode file. When that is the case, the command +`org-agenda-diary-entry' will be bound to the key given here, by default +`i'. In the calendar, `i' normally adds entries to `diary-file'. So +if you want to continue doing this, you need to change this to a different +key." + :group 'org-agenda + :type 'sexp) + +(defcustom org-agenda-diary-file 'diary-file + "File to which to add new entries with the `i' key in agenda and calendar. +When this is the symbol `diary-file', the functionality in the Emacs +calendar will be used to add entries to the `diary-file'. But when this +points to a file, `org-agenda-diary-entry' will be used instead." + :group 'org-agenda + :type '(choice + (const :tag "The standard Emacs diary file" diary-file) + (file :tag "Special Org file diary entries"))) + (eval-after-load "calendar" '(progn (org-defkey calendar-mode-map org-calendar-to-agenda-key 'org-calendar-goto-agenda) (org-defkey calendar-mode-map org-calendar-agenda-action-key - 'org-agenda-action))) + 'org-agenda-action) + (add-hook 'calendar-mode-hook + (lambda () + (unless (eq org-agenda-diary-file 'diary-file) + (define-key calendar-mode-map + org-calendar-insert-diary-entry-key + 'org-agenda-diary-entry)))))) (defgroup org-latex nil "Options for embedding LaTeX code into Org-mode." @@ -2749,7 +2895,7 @@ Changing this variable requires a restart of Emacs to take effect." (defcustom org-fontify-whole-heading-line nil "Non-nil means fontify the whole line for headings. This is useful when setting a background color for the -org-leve-* faces." +org-level-* faces." :group 'org-font-lock :type 'boolean) @@ -2905,7 +3051,7 @@ See also `org-completion-use-iswitchb'." Note that `iswitchb-mode' must be active for this variable to be relevant. If you decide to turn this variable on, you might well want to turn off `org-outline-path-complete-in-steps'. -Note that thi variable has only an effect if `org-completion-use-ido' is nil." +Note that this variable has only an effect if `org-completion-use-ido' is nil." :group 'org-completion :type 'boolean) @@ -2915,7 +3061,7 @@ Normal means, no org-mode-specific context." :group 'org-completion :type 'function) -;;; Functions and variables from ther packages +;;; Functions and variables from their packages ;; Declared here to avoid compiler warnings ;; XEmacs only @@ -2959,6 +3105,7 @@ Normal means, no org-mode-specific context." (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) (declare-function org-indent-mode "org-indent" (&optional arg)) (declare-function parse-time-string "parse-time" (string)) +(declare-function org-attach-reveal "org-attach" (&optional if-exists)) (defvar remember-data-file) (defvar texmathp-why) (declare-function speedbar-line-directory "speedbar" (&optional depth)) @@ -3131,11 +3278,15 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables." (declare-function org-clock-save-markers-for-cut-and-paste "org-clock" (beg end)) (declare-function org-clock-update-mode-line "org-clock" ()) +(declare-function org-resolve-clocks "org-clock" + (&optional also-non-dangling-p prompt last-valid)) (defvar org-clock-start-time) (defvar org-clock-marker (make-marker) "Marker recording the last clock-in.") (defvar org-clock-hd-marker (make-marker) "Marker recording the last clock-in, but the headline position.") +(defvar org-clock-heading "" + "The heading of the current clock entry.") (defun org-clock-is-active () "Return non-nil if clock is currently running. The return value is actually the clock marker." @@ -3148,7 +3299,7 @@ The return value is actually the clock marker." org-clock-goto org-clock-sum org-clock-display org-clock-remove-overlays org-clock-report org-clocktable-shift org-dblock-write:clocktable - org-get-clocktable))) + org-get-clocktable org-resolve-clocks))) (defun org-clock-update-time-maybe () "If this is a CLOCK line, update it and return t. @@ -3228,6 +3379,11 @@ If yes, offer to stop it and to save the buffer with the changes." ;; Autoload org-indent.el +;; Define the variable already here, to make sure we have it. +(defvar org-indent-mode nil + "Non-nil if Org-Indent mode is enabled. +Use the command `org-indent-mode' to change this variable.") + (eval-and-compile (org-autoload "org-indent" @@ -3280,7 +3436,7 @@ Here are a few examples: Archive in file ~/org/archive.org (absolute path), as top-level trees. \"~/org/archive.org::From %s\" - Archive in file ~/org/archive.org (absolute path), und headlines + Archive in file ~/org/archive.org (absolute path), under headlines \"From FILENAME\" where file name is the current file name. \"basement::** Finished Tasks\" @@ -3317,8 +3473,8 @@ Instead, use the key `v' to cycle the archives-mode in the agenda." :group 'org-agenda-skip :type 'boolean) -(defcustom org-columns-skip-arrchived-trees t - "Non-nil means, irgnore archived trees when creating column view." +(defcustom org-columns-skip-archived-trees t + "Non-nil means, ignore archived trees when creating column view." :group 'org-archive :group 'org-properties :type 'boolean) @@ -3367,9 +3523,17 @@ collapsed state." (let* ((re (concat ":" org-archive-tag ":"))) (goto-char beg) (while (re-search-forward re end t) - (and (org-on-heading-p) (hide-subtree)) + (and (org-on-heading-p) (org-flag-subtree t)) (org-end-of-subtree t))))) +(defun org-flag-subtree (flag) + (save-excursion + (org-back-to-heading t) + (outline-end-of-heading) + (outline-flag-region (point) + (progn (org-end-of-subtree t) (point)) + flag))) + (defalias 'org-advertized-archive-subtree 'org-archive-subtree) (eval-and-compile @@ -3513,7 +3677,7 @@ groups carry important information: "Regular expression to match a timestamp time or time range. After a match, the following groups carry important information: 0 the full match -1 date plus weekday, for backreferencing to make sure both times on same day +1 date plus weekday, for back referencing to make sure both times are on the same day 2 the first time, range or not 4 the second time, if it is a range.") @@ -3541,6 +3705,12 @@ After a match, the following groups carry important information: ("logrepeat" org-log-repeat state) ("lognoterepeat" org-log-repeat note) ("nologrepeat" org-log-repeat nil) + ("logreschedule" org-log-reschedule time) + ("lognotereschedule" org-log-reschedule note) + ("nologreschedule" org-log-reschedule nil) + ("logredeadline" org-log-redeadline time) + ("lognoteredeadline" org-log-redeadline note) + ("nologredeadline" org-log-redeadline nil) ("fninline" org-footnote-define-inline t) ("nofninline" org-footnote-define-inline nil) ("fnlocal" org-footnote-section nil) @@ -3927,7 +4097,6 @@ This is for getting out of special buffers like remember.") (defvar org-struct-menu) (defvar org-org-menu) (defvar org-tbl-menu) -(defvar org-agenda-keymap) ;;;; Define the Org-mode @@ -3945,8 +4114,6 @@ This variable is set by `org-before-change-function'. "Every change indicates that a table might need an update." (setq org-table-may-need-update t)) (defvar org-mode-map) -(defvar org-mode-hook nil - "Mode hook for Org-mode, run after the mode was turned on.") (defvar org-inhibit-startup nil) ; Dynamically-scoped param. (defvar org-agenda-keep-modes nil) ; Dynamically-scoped param. (defvar org-inhibit-logging nil) ; Dynamically-scoped param. @@ -4085,6 +4252,10 @@ The following commands are available: (org-indent-mode 1)) (org-set-startup-visibility))) +(when (fboundp 'abbrev-table-put) + (abbrev-table-put org-mode-abbrev-table + :parents (list text-mode-abbrev-table))) + (put 'org-mode 'flyspell-mode-predicate 'org-mode-flyspell-verify) (defun org-current-time () @@ -4649,6 +4820,13 @@ between words." t))) (defun org-outline-level () + "Compute the outline level of the heading at point. +This function assumes that the cursor is at the beginning of a line matched +by outline-regexp. Otherwise it returns garbage. +If this is called at a normal headline, the level is the number of stars. +Use `org-reduced-level' to remove the effect of `org-odd-levels'. +For plain list items, if they are matched by `outline-regexp', this returns +1000 plus the line indentation." (save-excursion (looking-at outline-regexp) (if (match-beginning 1) @@ -4824,11 +5002,17 @@ If KWD is a number, get the corresponding match group." (inhibit-read-only t) (inhibit-point-motion-hooks t) (inhibit-modification-hooks t) deactivate-mark buffer-file-name buffer-file-truename) - (remove-text-properties beg end - '(mouse-face t keymap t org-linked-text t - invisible t intangible t - line-prefix t wrap-prefix t - org-no-flyspell t)))) + (remove-text-properties + beg end + (if org-indent-mode + ;; also remove line-prefix and wrap-prefix properties + '(mouse-face t keymap t org-linked-text t + invisible t intangible t + line-prefix t wrap-prefix t + org-no-flyspell t) + '(mouse-face t keymap t org-linked-text t + invisible t intangible t + org-no-flyspell t))))) ;;;; Visibility cycling, including org-goto and indirect buffer @@ -4847,7 +5031,7 @@ If KWD is a number, get the corresponding match group." "TAB-action and visibility cycling for Org-mode. This is the command invoked in Org-mode by the TAB key. Its main purpose -is outine visibility cycling, but it also invokes other actions +is outline visibility cycling, but it also invokes other actions in special contexts. - When this function is called with a prefix argument, rotate the entire @@ -4885,7 +5069,10 @@ in special contexts. But only if also the variable `org-cycle-global-at-bob' is t." (interactive "P") (org-load-modules-maybe) - (unless (run-hook-with-args-until-success 'org-tab-first-hook) + (unless (or (run-hook-with-args-until-success 'org-tab-first-hook) + (and org-cycle-level-after-item/entry-creation + (or (org-cycle-level) + (org-cycle-item-indentation)))) (let* ((limit-level (or org-cycle-max-level (and (boundp 'org-inlinetask-min-level) @@ -4972,6 +5159,9 @@ in special contexts. ((org-try-cdlatex-tab)) + ((run-hook-with-args-until-success + 'org-tab-before-tab-emulation-hook)) + ((and (eq org-cycle-emulate-tab 'exc-hl-bol) (or (not (bolp)) (not (looking-at outline-regexp)))) @@ -5318,6 +5508,27 @@ are at least `org-cycle-separator-lines' empty lines before the headline." (let ((context (if (org-up-heading-safe) 'children 'overview))) (org-cycle-show-empty-lines context)))) +(defun org-files-list () + "Return `org-agenda-files' list, plus all open org-mode files. +This is useful for operations that need to scan all of a user's +open and agenda-wise Org files." + (let ((files (mapcar 'expand-file-name (org-agenda-files)))) + (dolist (buf (buffer-list)) + (with-current-buffer buf + (if (and (eq major-mode 'org-mode) (buffer-file-name)) + (let ((file (expand-file-name (buffer-file-name)))) + (unless (member file files) + (push file files)))))) + files)) + +(defsubst org-entry-beginning-position () + "Return the beginning position of the current entry." + (save-excursion (outline-back-to-heading t) (point))) + +(defsubst org-entry-end-position () + "Return the end position of the current entry." + (save-excursion (outline-next-heading) (point))) + (defun org-cycle-hide-drawers (state) "Re-hide all drawers after a visibility state change." (when (and (org-mode-p) @@ -5366,7 +5577,7 @@ Optional argument N means, put the headline into the Nth line of the window." "Regular expression for hiding blocks.") (defvar org-hide-block-overlays nil - "Overays hiding blocks.") + "Overlays hiding blocks.") (make-variable-buffer-local 'org-hide-block-overlays) (defun org-block-map (function &optional start end) @@ -5497,7 +5708,7 @@ RET=jump to location [Q]uit and return to previous location (defvar org-goto-start-pos) ; dynamically scoped parameter -;; FIXME: Docstring doe not mention both interfaces +;; FIXME: Docstring does not mention both interfaces (defun org-goto (&optional alternative-interface) "Look up a different location in the current file, keeping current visibility. @@ -5988,6 +6199,16 @@ in the region." ((eolp) (insert " ")) ((equal (char-after) ?\ ) (forward-char 1)))))) +(defun org-current-level () + "Return the level of the current entry, or nil if before the first headline. +The level is the number of stars at the beginning of the headline." + (save-excursion + (condition-case nil + (progn + (org-back-to-heading t) + (funcall outline-level)) + (error nil)))) + (defun org-reduced-level (l) "Compute the effective level of a heading. This takes into account the setting of `org-odd-levels-only'." @@ -6040,6 +6261,31 @@ in the region." (if org-adapt-indentation (org-fixup-indentation diff)) (run-hooks 'org-after-demote-entry-hook))) +(defvar org-tab-ind-state nil) + +(defun org-cycle-level () + (let ((org-adapt-indentation nil)) + (when (and (looking-at "[ \t]*$") + (looking-back + (concat "^\\(\\*+\\)[ \t]+\\(" org-todo-regexp "\\)?[ \t]*"))) + (setq this-command 'org-cycle-level) + (if (eq last-command 'org-cycle-level) + (condition-case nil + (progn (org-do-promote) + (if (equal org-tab-ind-state (org-current-level)) + (org-do-promote))) + (error + (progn + (save-excursion + (beginning-of-line 1) + (and (looking-at "\\*+") + (replace-match + (make-string org-tab-ind-state ?*)))) + (setq this-command 'org-cycle)))) + (setq org-tab-ind-state (- (match-end 1) (match-beginning 1))) + (org-do-demote)) + t))) + (defun org-map-tree (fun) "Call FUN for every heading underneath the current one." (org-back-to-heading) @@ -6489,6 +6735,7 @@ and still retain the repeater to cover future instances of the task." (org-back-to-heading t) (setq beg (point)) (org-end-of-subtree t t) + (or (bolp) (insert "\n")) (setq end (point)) (setq template (buffer-substring beg end)) (when (and doshift @@ -6565,7 +6812,7 @@ n Numerically, by converting the beginning of the entry/item to a number. a Alphabetically, ignoring the TODO keyword and the priority, if any. t By date/time, either the first active time stamp in the entry, or, if none exist, by the first inactive one. - In items, only the first line will be chekced. + In items, only the first line will be checked. s By the scheduled date/time. d By deadline date/time. c By creation time, which is assumed to be the first inactive time stamp @@ -7762,24 +8009,27 @@ from." (iswitchb-read-buffer prompt))) (defun org-icompleting-read (&rest args) - "Completing-read using `ido-mode' or `iswitchb' speedups if available" - (if (and org-completion-use-ido - (fboundp 'ido-completing-read) - (boundp 'ido-mode) ido-mode - (listp (second args))) - (let ((ido-enter-matching-directory nil)) - (apply 'ido-completing-read (concat (car args)) - (if (consp (car (nth 1 args))) - (mapcar (lambda (x) (car x)) (nth 1 args)) - (nth 1 args)) - (cddr args))) - (if (and org-completion-use-iswitchb - (boundp 'iswitchb-mode) iswitchb-mode - (listp (second args))) - (apply 'org-iswitchb-completing-read (concat (car args)) - (mapcar (lambda (x) (car x)) (nth 1 args)) - (cddr args)) - (apply 'completing-read args)))) + "Completing-read using `ido-mode' or `iswitchb' speedups if available." + (org-without-partial-completion + (if (and org-completion-use-ido + (fboundp 'ido-completing-read) + (boundp 'ido-mode) ido-mode + (listp (second args))) + (let ((ido-enter-matching-directory nil)) + (apply 'ido-completing-read (concat (car args)) + (if (consp (car (nth 1 args))) + (mapcar (lambda (x) (car x)) (nth 1 args)) + (nth 1 args)) + (cddr args))) + (if (and org-completion-use-iswitchb + (boundp 'iswitchb-mode) iswitchb-mode + (listp (second args))) + (apply 'org-iswitchb-completing-read (concat (car args)) + (if (consp (car (nth 1 args))) + (mapcar (lambda (x) (car x)) (nth 1 args)) + (nth 1 args)) + (cddr args)) + (apply 'completing-read args))))) (defun org-extract-attributes (s) "Extract the attributes cookie from a string and set as text property." @@ -7881,7 +8131,7 @@ This is still an experimental function, your mileage may vary." ;; Planner has a slash, we do not. (setq type "elisp" path (substring path 1))) ((string-match "^//\\(.?*\\)/\\(<.*>\\)$" path) - ;; A typical message link. Planner has the id after the fina slash, + ;; A typical message link. Planner has the id after the final slash, ;; we separate it with a hash mark (setq path (concat (match-string 1 path) "#" (org-remove-angle-brackets (match-string 2 path))))) @@ -7949,7 +8199,8 @@ application the system uses for this file type." org-bracket-link-regexp "\\|" org-angle-link-re "\\|" "[ \t]:[^ \t\n]+:[ \t]*$")))) - (org-offer-links-in-entry in-emacs)) + (or (org-offer-links-in-entry in-emacs) + (progn (require 'org-attach) (org-attach-reveal 'if-exists)))) ((org-at-timestamp-p t) (org-follow-timestamp-link)) ((or (org-footnote-at-reference-p) (org-footnote-at-definition-p)) (org-footnote-action)) @@ -8110,7 +8361,7 @@ application the system uses for this file type." (run-hook-with-args 'org-follow-link-hook)) (defun org-offer-links-in-entry (&optional nth zero) - "Offer links in the curren entry and follow the selected link. + "Offer links in the current entry and follow the selected link. If there is only one link, follow it immediately as well. If NTH is an integer, immediately pick the NTH link found. If ZERO is a string, check also this string for a link, and if @@ -8132,7 +8383,8 @@ there is one, offer it as link number zero." (setq links (org-uniquify (reverse links)))) (cond - ((null links) (error "No links")) + ((null links) + (message "No links")) ((equal (length links) 1) (setq link (car links))) ((and (integerp nth) (>= (length links) (if have-zero (1+ nth) nth))) @@ -8162,7 +8414,9 @@ there is one, offer it as link number zero." (unless (and (integerp nth) (>= (length links) nth)) (error "Invalid link selection")) (setq link (nth (1- nth) links)))) - (org-open-link-from-string link in-emacs (current-buffer)))) + (if link + (progn (org-open-link-from-string link in-emacs (current-buffer)) t) + nil))) ;;;; Time estimates @@ -8674,7 +8928,7 @@ on the system \"/user@host:\"." (t (error "Bad refiling target description %s" desc))) (while (setq f (pop files)) (with-current-buffer - (if (bufferp f) f (org-get-agenda-file-buffer f)) + (if (bufferp f) f (org-get-agenda-file-buffer f)) (if (bufferp f) (setq f (buffer-file-name (buffer-base-buffer f)))) (setq f (expand-file-name f)) (if (eq org-refile-use-outline-path 'file) @@ -8770,6 +9024,7 @@ With prefix arg GOTO, the command will only visit the target location, not actually move anything. With a double prefix `C-u C-u', go to the location where the last refiling operation has put the subtree. +With a prefix argument of `2', refile to the running clock. RFLOC can be a refile location obtained in a different way. @@ -8791,11 +9046,21 @@ See also `org-refile-use-outline-path' and `org-completion-use-ido'" (error "The region is not a (sequence of) subtree(s)"))) (if (equal goto '(16)) (org-refile-goto-last-stored) - (when (setq it (or rfloc - (save-excursion - (org-refile-get-location - (if goto "Goto: " "Refile to: ") default-buffer - org-refile-allow-creating-parent-nodes)))) + (when (or + (and (equal goto 2) + org-clock-hd-marker (marker-buffer org-clock-hd-marker) + (prog1 + (setq it (list (or org-clock-heading "running clock") + (buffer-file-name + (marker-buffer org-clock-hd-marker)) + "" + (marker-position org-clock-hd-marker))) + (setq goto nil))) + (setq it (or rfloc + (save-excursion + (org-refile-get-location + (if goto "Goto: " "Refile to: ") default-buffer + org-refile-allow-creating-parent-nodes))))) (setq file (nth 1 it) re (nth 2 it) pos (nth 3 it)) @@ -8823,7 +9088,7 @@ See also `org-refile-use-outline-path' and `org-completion-use-ido'" (org-save-markers-in-region region-start region-end)) (org-copy-subtree 1 nil t)) (with-current-buffer (setq nbuf (or (find-buffer-visiting file) - (find-file-noselect file))) + (find-file-noselect file))) (setq reversed (org-notes-order-reversed-p)) (save-excursion (save-restriction @@ -8992,7 +9257,7 @@ If not found, stay at current position and return nil." (defconst org-dblock-start-re "^[ \t]*#\\+BEGIN:[ \t]+\\(\\S-+\\)\\([ \t]+\\(.*\\)\\)?" - "Matches the startline of a dynamic block, with parameters.") + "Matches the start line of a dynamic block, with parameters.") (defconst org-dblock-end-re "^[ \t]*#\\+END\\([: \t\r\n]\\|$\\)" "Matches the end of a dynamic block.") @@ -9129,6 +9394,7 @@ This function can be used in a hook." "BEGIN_SRC" "END_SRC" "CATEGORY" "COLUMNS" "CAPTION" "LABEL" + "SETUPFILE" "BIND" "MACRO")) @@ -9412,7 +9678,7 @@ DONE are present, add TODO at the beginning of the heading. With C-u prefix arg, use completion to determine the new state. With numeric prefix arg, switch to that state. With a double C-u prefix, switch to the next set of TODO keywords (nextset). -With a tripple C-u prefix, circumvent any state blocking. +With a triple C-u prefix, circumvent any state blocking. For calling through lisp, arg is also interpreted in the following way: 'none -> empty state @@ -9434,7 +9700,7 @@ For calling through lisp, arg is also interpreted in the following way: (setq org-blocker-hook nil)) (save-excursion (catch 'exit - (org-back-to-heading) + (org-back-to-heading t) (if (looking-at outline-regexp) (goto-char (1- (match-end 0)))) (or (looking-at (concat " +" org-todo-regexp "\\( +\\|$\\)")) (looking-at " *")) @@ -9500,6 +9766,8 @@ For calling through lisp, arg is also interpreted in the following way: (or (car (cdr (member head org-todo-heads))) (car org-todo-heads)))) ((car (member arg org-todo-keywords-1))) + ((stringp arg) + (error "State `%s' not valid in this file" arg)) ((nth (1- (prefix-numeric-value arg)) org-todo-keywords-1)))) ((null member) (or head (car org-todo-keywords-1))) @@ -9627,7 +9895,8 @@ changes. Such blocking occurs when: (member (plist-get change-plist :from) (cons 'done org-done-keywords)) (member (plist-get change-plist :to) - (cons 'todo org-not-done-keywords))) + (cons 'todo org-not-done-keywords)) + (not (plist-get change-plist :to))) (throw 'dont-block t)) ;; If this task has children, and any are undone, it's blocked (save-excursion @@ -9709,7 +9978,7 @@ See variable `org-track-ordered-property-with-tag'." (defun org-block-todo-from-checkboxes (change-plist) "Block turning an entry into a TODO, using checkboxes. This checks whether the current task should be blocked from state -changes because there are uncheckd boxes in this entry." +changes because there are unchecked boxes in this entry." (catch 'dont-block ;; If this is not a todo state change, or if this entry is already DONE, ;; do not block @@ -9717,7 +9986,8 @@ changes because there are uncheckd boxes in this entry." (member (plist-get change-plist :from) (cons 'done org-done-keywords)) (member (plist-get change-plist :to) - (cons 'todo org-not-done-keywords))) + (cons 'todo org-not-done-keywords)) + (not (plist-get change-plist :to))) (throw 'dont-block t)) ;; If this task has checkboxes that are not checked, it's blocked (save-excursion @@ -9796,7 +10066,7 @@ statistics everywhere." (while (and (setq level (org-up-heading-safe)) (or recursive first) (>= (point) lim)) - (setq first nil) + (setq first nil cookie-present nil) (unless (and level (not (string-match "\\<checkbox\\>" @@ -9831,10 +10101,10 @@ statistics everywhere." ndel (- (match-end 0) (match-beginning 0))) (goto-char (match-beginning 0)) (insert new) - (delete-region (point) (+ (point) ndel)))) - (when cookie-present - (run-hook-with-args 'org-after-todo-statistics-hook - cnt-done (- cnt-all cnt-done))))) + (delete-region (point) (+ (point) ndel))) + (when cookie-present + (run-hook-with-args 'org-after-todo-statistics-hook + cnt-done (- cnt-all cnt-done)))))) (run-hooks 'org-todo-statistics-hook))) (defvar org-after-todo-statistics-hook nil @@ -9855,7 +10125,7 @@ when there is a statistics cookie in the headline! (defvar org-todo-statistics-hook nil "Hook that is run whenever Org thinks TODO statistics should be updated. -This hook runs even if there is no statisics cookie present, in which case +This hook runs even if there is no statistics cookie present, in which case `org-after-todo-statistics-hook' would not run.") (defun org-todo-trigger-tag-changes (state) @@ -10004,14 +10274,16 @@ Returns the new TODO keyword, or nil if no state change should occur." (throw 'exit t))) nil))) -(defun org-get-repeat () +(defun org-get-repeat (&optional tagline) "Check if there is a deadline/schedule with repeater in this entry." (save-match-data (save-excursion (org-back-to-heading t) - (if (re-search-forward - org-repeat-re (save-excursion (outline-next-heading) (point)) t) - (match-string 1))))) + (and (re-search-forward (if tagline + (concat tagline "\\s-*" org-repeat-re) + org-repeat-re) + (org-entry-end-position) t) + (match-string-no-properties 1))))) (defvar org-last-changed-timestamp) (defvar org-last-inserted-timestamp) @@ -10124,29 +10396,41 @@ With argument REMOVE, remove any deadline from the item. When TIME is set, it should be an internal time specification, and the scheduling will use the corresponding date." (interactive "P") - (if remove - (progn - (org-remove-timestamp-with-keyword org-deadline-string) - (message "Item no longer has a deadline.")) - (if (org-get-repeat) - (error "Cannot change deadline on task with repeater, please do that by hand") - (org-add-planning-info 'deadline time 'closed) - (message "Deadline on %s" org-last-inserted-timestamp)))) - + (let ((old-date (org-entry-get nil "DEADLINE"))) + (if remove + (progn + (org-remove-timestamp-with-keyword org-deadline-string) + (message "Item no longer has a deadline.")) + (if (org-get-repeat) + (error "Cannot change deadline on task with repeater, please do that by hand") + (org-add-planning-info 'deadline time 'closed) + (when (and old-date org-log-redeadline + (not (equal old-date + (substring org-last-inserted-timestamp 1 -1)))) + (org-add-log-setup 'redeadline nil old-date 'findpos + org-log-redeadline)) + (message "Deadline on %s" org-last-inserted-timestamp))))) + (defun org-schedule (&optional remove time) "Insert the SCHEDULED: string with a timestamp to schedule a TODO item. With argument REMOVE, remove any scheduling date from the item. When TIME is set, it should be an internal time specification, and the scheduling will use the corresponding date." (interactive "P") - (if remove - (progn - (org-remove-timestamp-with-keyword org-scheduled-string) - (message "Item is no longer scheduled.")) - (if (org-get-repeat) - (error "Cannot reschedule task with repeater, please do that by hand") - (org-add-planning-info 'scheduled time 'closed) - (message "Scheduled to %s" org-last-inserted-timestamp)))) + (let ((old-date (org-entry-get nil "SCHEDULED"))) + (if remove + (progn + (org-remove-timestamp-with-keyword org-scheduled-string) + (message "Item is no longer scheduled.")) + (if (org-get-repeat) + (error "Cannot reschedule task with repeater, please do that by hand") + (org-add-planning-info 'scheduled time 'closed) + (when (and old-date org-log-reschedule + (not (equal old-date + (substring org-last-inserted-timestamp 1 -1)))) + (org-add-log-setup 'reschedule nil old-date 'findpos + org-log-reschedule)) + (message "Scheduled to %s" org-last-inserted-timestamp))))) (defun org-get-scheduled-time (pom &optional inherit) "Get the scheduled time as a time tuple, of a format suitable @@ -10158,7 +10442,7 @@ returns nil." (defun org-get-deadline-time (pom &optional inherit) "Get the deadine as a time tuple, of a format suitable for -calling org-deadlin with, or if there is no scheduling, returns +calling org-deadline with, or if there is no scheduling, returns nil." (let ((time (org-entry-get pom "DEADLINE" inherit))) (when time @@ -10258,6 +10542,7 @@ be removed." (skip-chars-backward " ") (if (looking-at " +") (replace-match "")))) (goto-char (point-max)) + (and org-adapt-indentation (bolp) (org-indent-to-column col)) (when what (insert (if (not (or (bolp) (eq (char-before) ?\ ))) " " "") @@ -10387,6 +10672,10 @@ EXTRA is additional text that will be inserted into the notes buffer." (format "state change from \"%s\" to \"%s\"" (or org-log-note-previous-state "") (or org-log-note-state ""))) + ((eq org-log-note-purpose 'reschedule) + "rescheduling") + ((eq org-log-note-purpose 'redeadline) + "changing deadline") ((eq org-log-note-purpose 'note) "this entry") (t (error "This should not happen"))))) @@ -10452,7 +10741,7 @@ EXTRA is additional text that will be inserted into the notes buffer." (and org-log-post-message (message "%s" org-log-post-message))) (defun org-remove-empty-drawer-at (drawer pos) - "Remove an emptyr DARWER drawer at position POS. + "Remove an empty drawer DRAWER at position POS. POS may also be a marker." (with-current-buffer (if (markerp pos) (marker-buffer pos) (current-buffer)) (save-excursion @@ -10472,7 +10761,7 @@ t Show entries with a specific TODO keyword. m Show entries selected by a tags/property match. p Enter a property name and its value (both with completion on existing names/values) and show entries with that property. -r Show entries matching a regular expression. +/ Show entries matching a regular expression (`r' can be used as well) d Show deadlines due within `org-deadline-warning-days'. b Show deadlines and scheduled items before a date. a Show deadlines and scheduled items after a date." @@ -10656,6 +10945,8 @@ ACTION can be `set', `up', `down', or a character." have t) (setq current org-default-priority)) (cond + ((eq action 'remove) + (setq remove t new ?\ )) ((or (eq action 'set) (if (featurep 'xemacs) (characterp action) (integerp action))) (if (not (eq action 'set)) @@ -10717,7 +11008,7 @@ ACTION can be `set', `up', `down', or a character." (defvar org-agenda-archives-mode) (defvar org-map-continue-from nil "Position from where mapping should continue. -Can be set byt the action argument to `org-scan-tag's and `org-map-entries'.") +Can be set by the action argument to `org-scan-tag's and `org-map-entries'.") (defvar org-scanner-tags nil "The current tag list while the tags scanner is running.") @@ -10754,7 +11045,6 @@ only lines with a TODO keyword are included in the output." 'mouse-face 'highlight 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name @@ -11497,15 +11787,15 @@ Returns the new tags string, or nil to not change the current settings." (setq tbl fulltable char ?a cnt 0) (while (setq e (pop tbl)) (cond - ((equal e '(:startgroup)) + ((equal (car e) :startgroup) (push '() groups) (setq ingroup t) (when (not (= cnt 0)) (setq cnt 0) (insert "\n")) - (insert "{ ")) - ((equal e '(:endgroup)) + (insert (if (cdr e) (format "%s: " (cdr e)) "") "{ ")) + ((equal (car e) :endgroup) (setq ingroup nil cnt 0) - (insert "}\n")) + (insert "}" (if (cdr e) (format " (%s) " (cdr e)) "") "\n")) ((equal e '(:newline)) (when (not (= cnt 0)) (setq cnt 0) @@ -11550,8 +11840,8 @@ Returns the new tags string, or nil to not change the current settings." (setq rtn (catch 'exit (while t - (message "[a-z..]:Toggle [SPC]:clear [RET]:accept [TAB]:free%s%s" - (if groups " [!] no groups" " [!]groups") + (message "[a-z..]:Toggle [SPC]:clear [RET]:accept [TAB]:free [!] %sgroups%s" + (if (not groups) "no " "") (if expert " [C-c]:window" (if exit-after-next " [C-c]:single" " [C-c]:multi"))) (setq c (let ((inhibit-quit t)) (read-char-exclusive))) (cond @@ -11656,6 +11946,7 @@ Returns the new tags string, or nil to not change the current settings." (when (equal (char-after (point-at-bol 0)) ?*) (mapc (lambda (x) (add-to-list 'tags x)) (org-split-string (org-match-string-no-properties 1) ":"))))) + (mapc (lambda (s) (add-to-list 'tags s)) org-file-tags) (mapcar 'list tags))) ;;;; The mapping API @@ -11788,7 +12079,7 @@ but in some other way.") "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE" "EXPORT_FILE_NAME" "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" - "CLOCK_MODELINE_TOTAL") + "CLOCK_MODELINE_TOTAL" "STYLE") "Some properties that are used by Org-mode for various purposes. Being in this list makes sure that they are offered for completion.") @@ -11843,13 +12134,24 @@ allowed value." (cur (org-entry-get nil prop)) (allowed (org-property-get-allowed-values nil prop 'table)) (existing (mapcar 'list (org-property-values prop))) + rpl (val (cond ((stringp value) value) ((and allowed (integerp value)) (or (car (nth (1- value) allowed)) (car (org-last allowed)))) (allowed - (org-completing-read "Value: " allowed nil 'req-match)) + (message "Select 1-9,0, [RET%s]: %s" + (if cur (concat "=" cur) "") + (mapconcat 'car allowed " ")) + (setq rpl (read-char-exclusive)) + (if (equal rpl ?\r) + cur + (setq rpl (- rpl ?0)) + (if (equal rpl 0) (setq rpl 10)) + (if (and (> rpl 0) (<= rpl (length allowed))) + (car (nth (1- rpl) allowed)) + (org-completing-read "Value: " allowed nil)))) (t (let (org-completion-use-ido org-completion-use-iswitchb) (org-completing-read @@ -12699,6 +13001,7 @@ user." (defvar def) (defvar defdecode) (defvar with-time) +(defvar org-read-date-analyze-futurep nil) (defun org-read-date-display () "Display the current date prompt interpretation in the minibuffer." (when org-read-date-display-live @@ -12728,6 +13031,8 @@ user." (setq txt (concat (substring txt 0 (match-end 0)) "-" org-end-time-was-given (substring txt (match-end 0))))) + (when org-read-date-analyze-futurep + (setq txt (concat txt " (=>F)"))) (setq org-read-date-overlay (org-make-overlay (1- (point-at-eol)) (point-at-eol))) (org-overlay-display org-read-date-overlay txt 'secondary-selection)))) @@ -12737,8 +13042,8 @@ user." ;; FIXME: cleanup and comment (let (delta deltan deltaw deltadef year month day hour minute second wday pm h2 m2 tl wday1 - iso-year iso-weekday iso-week iso-year iso-date) - + iso-year iso-weekday iso-week iso-year iso-date futurep) + (setq org-read-date-analyze-futurep nil) (when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans) (setq ans "+0")) @@ -12811,22 +13116,36 @@ user." month (or (nth 4 tl) (if (and org-read-date-prefer-future (nth 3 tl) (< (nth 3 tl) (nth 3 defdecode))) - (1+ (nth 4 defdecode)) + (prog1 (1+ (nth 4 defdecode)) (setq futurep t)) (nth 4 defdecode))) year (or (nth 5 tl) (if (and org-read-date-prefer-future (nth 4 tl) (< (nth 4 tl) (nth 4 defdecode))) - (1+ (nth 5 defdecode)) + (prog1 (1+ (nth 5 defdecode)) (setq futurep t)) (nth 5 defdecode))) hour (or (nth 2 tl) (nth 2 defdecode)) minute (or (nth 1 tl) (nth 1 defdecode)) second (or (nth 0 tl) 0) wday (nth 6 tl)) + (when (and (eq org-read-date-prefer-future 'time) + (not (nth 3 tl)) (not (nth 4 tl)) (not (nth 5 tl)) + (equal day (nth 3 defdecode)) + (equal month (nth 4 defdecode)) + (equal year (nth 5 defdecode)) + (nth 2 tl) + (or (< (nth 2 tl) (nth 2 defdecode)) + (and (= (nth 2 tl) (nth 2 defdecode)) + (nth 1 tl) + (< (nth 1 tl) (nth 1 defdecode))))) + (setq day (1+ day) + futurep t)) + ;; Special date definitions below (cond (iso-week ;; There was an iso week + (setq futurep nil) (setq year (or iso-year year) day (or iso-weekday wday 1) wday nil ; to make sure that the trigger below does not match @@ -12846,6 +13165,7 @@ user." year (nth 2 iso-date) day (nth 1 iso-date))) (deltan + (setq futurep nil) (unless deltadef (let ((now (decode-time (current-time)))) (setq day (nth 3 now) month (nth 4 now) year (nth 5 now)))) @@ -12854,6 +13174,7 @@ user." ((equal deltaw "m") (setq month (+ month deltan))) ((equal deltaw "y") (setq year (+ year deltan))))) ((and wday (not (nth 3 tl))) + (setq futurep nil) ;; Weekday was given, but no day, so pick that day in the week ;; on or after the derived date. (setq wday1 (nth 6 (decode-time (encode-time 0 0 0 day month year)))) @@ -12864,6 +13185,7 @@ user." (setq org-time-was-given t)) (if (< year 100) (setq year (+ 2000 year))) (if (< year 1970) (setq year (nth 5 defdecode))) ; not representable + (setq org-read-date-analyze-futurep futurep) (list second minute hour day month year))) (defvar parse-time-weekdays) @@ -12982,7 +13304,7 @@ The command returns the inserted time stamp." t1 w1 with-hm tf time str w2 (off 0)) (save-match-data (setq t1 (org-parse-time-string ts t)) - (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\( [.+]?\\+[0-9]+[dwmy]\\)?\\'" ts) + (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\( [.+]?\\+[0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)?\\'" ts) (setq off (- (match-end 0) (match-beginning 0))))) (setq end (- end off)) (setq w1 (- end beg) @@ -13494,7 +13816,7 @@ in the timestamp determines what will be changed." ts (match-string 0)) (replace-match "") (if (string-match - "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?[-+][0-9]+[dwmy]\\)*\\)[]>]" + "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?[-+][0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)*\\)[]>]" ts) (setq extra (match-string 1 ts))) (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts) @@ -13637,7 +13959,7 @@ If there is already a time stamp at the cursor position, update it." (defun org-hh:mm-string-to-minutes (s) "Convert a string H:MM to a number of minutes. -If the string is just a number, interprete it as minutes. +If the string is just a number, interpret it as minutes. In fact, the first hh:mm or number in the string will be taken, there can be extra stuff in the string. If no number is found, the return value is 0." @@ -14398,7 +14720,7 @@ Some of the options can be changed using the variable (org-defkey org-mode-map "\C-c\C-b" 'org-backward-same-level) (org-defkey org-mode-map "\C-c$" 'org-archive-subtree) (org-defkey org-mode-map "\C-c\C-x\C-s" 'org-advertized-archive-subtree) -(org-defkey org-mode-map "\C-c\C-x\C-a" 'org-toggle-archive-tag) +(org-defkey org-mode-map "\C-c\C-x\C-a" 'org-archive-subtree-default) (org-defkey org-mode-map "\C-c\C-xa" 'org-toggle-archive-tag) (org-defkey org-mode-map "\C-c\C-xA" 'org-archive-to-archive-sibling) (org-defkey org-mode-map "\C-c\C-xb" 'org-tree-to-indirect-buffer) @@ -14505,34 +14827,115 @@ Some of the options can be changed using the variable (org-defkey org-mode-map 'button3 'popup-mode-menu)) +(defconst org-speed-commands-default + '( + ("n" . outline-next-visible-heading) + ("p" . outline-previous-visible-heading) + ("f" . org-forward-same-level) + ("b" . org-backward-same-level) + ("u" . outline-up-heading) + + ("c" . org-cycle) + ("C" . org-shifttab) + ("U" . org-shiftmetaup) + ("D" . org-shiftmetadown) + ("r" . org-metaright) + ("l" . org-metaleft) + ("R" . org-shiftmetaright) + ("L" . org-shiftmetaleft) + ("i" . (progn (forward-char 1) (call-interactively + 'org-insert-heading-respect-content))) + + ("a" . org-agenda) + ("/" . org-sparse-tree) + (";" . org-set-tags-command) + ("I" . org-clock-in) + ("O" . org-clock-out) + ("o" . org-open-at-point) + ("t" . org-todo) + ("j" . org-goto) + ("g" . (org-refile t)) + ("e" . org-set-effort) + ("0" . (org-priority ?\ )) + ("1" . (org-priority ?A)) + ("2" . (org-priority ?B)) + ("3" . (org-priority ?C)) + ("." . outline-mark-subtree) + ("^" . org-sort) + ("w" . org-refile) + ("a" . org-archive-subtree-default-with-confirmation) + ("/" . org-sparse-tree) + ("?" . org-speed-command-help) + ) + "The default speed commands.") + +(defun org-print-speed-command (e) + (princ (car e)) + (princ " ") + (if (symbolp (cdr e)) + (princ (symbol-name (cdr e))) + (prin1 (cdr e))) + (princ "\n")) + +(defun org-speed-command-help () + "Show the available speed commands." + (interactive) + (if (not org-use-speed-commands) + (error "Speed commands are not activated, customize `org-use-speed-commands'.") + (with-output-to-temp-buffer "*Help*" + (princ "Speed commands\n==============\n") + (mapc 'org-print-speed-command org-speed-commands-user) + (princ "\n") + (mapc 'org-print-speed-command org-speed-commands-default)))) + (defvar org-self-insert-command-undo-counter 0) (defvar org-table-auto-blank-field) ; defined in org-table.el +(defvar org-speed-command nil) (defun org-self-insert-command (N) "Like `self-insert-command', use overwrite-mode for whitespace in tables. If the cursor is in a table looking at whitespace, the whitespace is overwritten, and the table is not marked as requiring realignment." (interactive "p") - (if (and - (org-table-p) - (progn - ;; check if we blank the field, and if that triggers align - (and (featurep 'org-table) org-table-auto-blank-field - (member last-command - '(org-cycle org-return org-shifttab org-ctrl-c-ctrl-c yas/expand)) - (if (or (equal (char-after) ?\ ) (looking-at "[^|\n]* |")) - ;; got extra space, this field does not determine column width - (let (org-table-may-need-update) (org-table-blank-field)) + (cond + ((and org-use-speed-commands + (bolp) + (looking-at outline-regexp) + (setq + org-speed-command + (or (cdr (assoc (this-command-keys) org-speed-commands-user)) + (cdr (assoc (this-command-keys) org-speed-commands-default))))) + (cond + ((commandp org-speed-command) + (setq this-command org-speed-command) + (call-interactively org-speed-command)) + ((functionp org-speed-command) + (funcall org-speed-command)) + ((and org-speed-command (listp org-speed-command)) + (eval org-speed-command)) + (t (let (org-use-speed-commands) + (call-interactively 'org-self-insert-command))))) + ((and + (org-table-p) + (progn + ;; check if we blank the field, and if that triggers align + (and (featurep 'org-table) org-table-auto-blank-field + (member last-command + '(org-cycle org-return org-shifttab org-ctrl-c-ctrl-c yas/expand)) + (if (or (equal (char-after) ?\ ) (looking-at "[^|\n]* |")) + ;; got extra space, this field does not determine column width + (let (org-table-may-need-update) (org-table-blank-field)) ;; no extra space, this field may determine column width - (org-table-blank-field))) - t) - (eq N 1) - (looking-at "[^|\n]* |")) - (let (org-table-may-need-update) - (goto-char (1- (match-end 0))) - (delete-backward-char 1) - (goto-char (match-beginning 0)) - (self-insert-command N)) + (org-table-blank-field))) + t) + (eq N 1) + (looking-at "[^|\n]* |")) + (let (org-table-may-need-update) + (goto-char (1- (match-end 0))) + (delete-backward-char 1) + (goto-char (match-beginning 0)) + (self-insert-command N))) + (t (setq org-table-may-need-update t) (self-insert-command N) (org-fix-tags-on-the-fly) @@ -14546,7 +14949,7 @@ overwritten, and the table is not marked as requiring realignment." (not (cadr buffer-undo-list)) ; remove nil entry (setcdr buffer-undo-list (cddr buffer-undo-list))) (setq org-self-insert-command-undo-counter - (1+ org-self-insert-command-undo-counter))))))) + (1+ org-self-insert-command-undo-counter)))))))) (defun org-fix-tags-on-the-fly () (when (and (equal (char-after (point-at-bol)) ?*) @@ -14676,6 +15079,12 @@ This hook runs after it has been established that not table field motion and not visibility should be done because of current context. This is probably the place where a package like yasnippets can hook in.") +(defvar org-tab-before-tab-emulation-hook nil + "Hook for functions to attach themselves to TAB. +See `org-ctrl-c-ctrl-c-hook' for more information. +This hook runs after every other options for TAB have been exhausted, but +before indentation and \t insertion takes place.") + (defvar org-metaleft-hook nil "Hook for functions attaching themselves to `M-left'. See `org-ctrl-c-ctrl-c-hook' for more information.") @@ -15443,21 +15852,11 @@ See the individual commands for more information." ["Footnote new/jump" org-footnote-action t] ["Footnote extra" (org-footnote-action t) :active t :keys "C-u C-c C-x f"]) ("Archive" - ["Toggle ARCHIVE tag" org-toggle-archive-tag t] -; ["Check and Tag Children" (org-toggle-archive-tag (4)) -; :active t :keys "C-u C-c C-x C-a"] - ["Sparse trees open ARCHIVE trees" - (setq org-sparse-tree-open-archived-trees - (not org-sparse-tree-open-archived-trees)) - :style toggle :selected org-sparse-tree-open-archived-trees] - ["Cycling opens ARCHIVE trees" - (setq org-cycle-open-archived-trees (not org-cycle-open-archived-trees)) - :style toggle :selected org-cycle-open-archived-trees] + ["Archive (default method)" org-archive-subtree-default t] "--" - ["Move subtree to archive sibling" org-archive-to-archive-sibling t] - ["Move Subtree to Archive" org-advertized-archive-subtree t] - ; ["Check and Move Children" (org-archive-subtree '(4)) - ; :active t :keys "C-u C-c C-x C-s"] + ["Move Subtree to Archive file" org-advertized-archive-subtree t] + ["Toggle ARCHIVE tag" org-toggle-archive-tag t] + ["Move subtree to Archive sibling" org-archive-to-archive-sibling t] ) "--" ("Hyperlinks" @@ -15795,6 +16194,10 @@ With prefix arg UNCOMPILED, load the uncompiled versions." "Is point in a line starting with `#'?" (equal (char-after (point-at-bol)) ?#)) +(defun org-in-verbatim-emphasis () + (save-match-data + (and (org-in-regexp org-emph-re 2) (member (match-string 3) '("=" "~"))))) + (defun org-goto-marker-or-bmk (marker &optional bookmark) "Go to MARKER, widen if necessary. When marker is not live, try BOOKMARK." (if (and marker (marker-buffer marker) @@ -15913,6 +16316,18 @@ N may optionally be the number of spaces to remove." (end-of-line 1)) min))) +(defun org-fill-template (template alist) + "Find each %key of ALIST in TEMPLATE and replace it." + (let (entry key value) + (setq alist (sort (copy-sequence alist) + (lambda (a b) (< (length (car a)) (length (car b)))))) + (while (setq entry (pop alist)) + (setq template + (replace-regexp-in-string + (concat "%" (regexp-quote (car entry))) + (cdr entry) template t t))) + template)) + (defun org-base-buffer (buffer) "Return the base buffer of BUFFER, if it has one. Else return the buffer." (if (not buffer) @@ -16041,7 +16456,7 @@ and :keyword." (push (org-point-in-group p 2 :todo-keyword) clist) (push (org-point-in-group p 4 :tags) clist)) (goto-char p) - (skip-chars-backward "^[\n\r \t") (or (eobp) (backward-char 1)) + (skip-chars-backward "^[\n\r \t") (or (bobp) (backward-char 1)) (if (looking-at "\\[#[A-Z0-9]\\]") (push (org-point-in-group p 0 :priority) clist))) @@ -16422,9 +16837,10 @@ which make use of the date at the cursor." (beginning-of-line 1) (if (looking-at "\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)") - (replace-match (concat "\\1" (format org-property-format - (match-string 2) (match-string 3))) - t nil)) + (replace-match (concat (match-string 1) + (format org-property-format + (match-string 2) (match-string 3))) + t t)) (org-move-to-column column))) (defun org-set-autofill-regexps () @@ -16560,7 +16976,7 @@ This looks for a line like #+BIBLIOGRAPHY: foo plain option:-d -and derives from it that foo.bib is the bbliography file relevant +and derives from it that foo.bib is the bibliography file relevant for this document. It then installs the necessary environment for RefTeX to work in this buffer and calls `reftex-citation' to insert a citation into the buffer. @@ -17162,10 +17578,11 @@ Show the heading too, if it is currently invisible." if no description is present" (save-match-data (if (string-match org-bracket-link-analytic-regexp link) - (replace-match (or (match-string 5 link) - (concat (match-string 1 link) - (match-string 3 link))) - nil nil link) + (replace-match (if (match-end 5) + (match-string 5 link) + (concat (match-string 1 link) + (match-string 3 link))) + nil t link) link))) ;; Speedbar support @@ -17188,12 +17605,9 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." ((setq p (text-property-any (point-at-bol) (point-at-eol) 'org-imenu t)) (setq m (get-text-property p 'org-imenu-marker)) - (save-excursion - ;; FIXME: Shouldn't set-buffer be done before save-restriction? --Stef - (save-restriction - (set-buffer (marker-buffer m)) - (goto-char m) - (org-agenda-set-restriction-lock 'subtree)))) + (with-current-buffer (marker-buffer m) + (goto-char m) + (org-agenda-set-restriction-lock 'subtree))) ((setq p (text-property-any (point-at-bol) (point-at-eol) 'speedbar-function 'speedbar-find-file)) (setq tp (previous-single-property-change @@ -17203,15 +17617,12 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." dir (speedbar-line-directory) txt (buffer-substring-no-properties (or tp (point-min)) (or np (point-max)))) - (save-excursion - ;; FIXME: Shouldn't set-buffer be done before save-restriction? --Stef - (save-restriction - (set-buffer (find-file-noselect - (let ((default-directory dir)) - (expand-file-name txt)))) - (unless (org-mode-p) - (error "Cannot restrict to non-Org-mode file")) - (org-agenda-set-restriction-lock 'file)))) + (with-current-buffer (find-file-noselect + (let ((default-directory dir)) + (expand-file-name txt))) + (unless (org-mode-p) + (error "Cannot restrict to non-Org-mode file")) + (org-agenda-set-restriction-lock 'file))) (t (error "Don't know how to restrict Org-mode's agenda"))) (org-move-overlay org-speedbar-restriction-lock-overlay (point-at-bol) (point-at-eol)) @@ -17244,7 +17655,7 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." (flyspell-delete-region-overlays beg end)) (add-text-properties beg end '(org-no-flyspell t))) -;; Make `bookmark-jump' show the jump location if it was hidden. +;; Make `bookmark-jump' shows the jump location if it was hidden. (eval-after-load "bookmark" '(if (boundp 'bookmark-after-jump-hook) ;; We can use the hook @@ -17254,12 +17665,19 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." "Make the position visible." (org-bookmark-jump-unhide)))) -;; Make sure saveplace show the location if it was hidden +;; Make sure saveplace shows the location if it was hidden (eval-after-load "saveplace" '(defadvice save-place-find-file-hook (after org-make-visible activate) "Make the position visible." (org-bookmark-jump-unhide))) +;; Make sure ecb shows the location if it was hidden +(eval-after-load "ecb" + '(defadvice ecb-method-clicked (after esf/org-show-context activate) + "Make hierarchy visible when jumping into location from ECB tree buffer." + (if (eq major-mode 'org-mode) + (org-show-context)))) + (defun org-bookmark-jump-unhide () "Unhide the current position, to show the bookmark location." (and (org-mode-p) @@ -17304,3 +17722,4 @@ Still experimental, may disappear in the future." ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd ;;; org.el ends here + |